diff options
Diffstat (limited to 'fs/xfs/libxfs/xfs_metadir.c')
| -rw-r--r-- | fs/xfs/libxfs/xfs_metadir.c | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/fs/xfs/libxfs/xfs_metadir.c b/fs/xfs/libxfs/xfs_metadir.c index 3e5c61188927..7c6b086b73db 100644 --- a/fs/xfs/libxfs/xfs_metadir.c +++ b/fs/xfs/libxfs/xfs_metadir.c @@ -95,7 +95,7 @@ xfs_metadir_lookup( .hashval = xfs_dir2_hashname(mp, xname), .whichfork = XFS_DATA_FORK, .op_flags = XFS_DA_OP_OKNOENT, - .owner = dp->i_ino, + .owner = I_INO(dp), }; int error; @@ -182,7 +182,7 @@ xfs_metadir_teardown( * Begin the process of creating a metadata file by allocating transactions * and taking whatever resources we're going to need. */ -int +static int xfs_metadir_start_create( struct xfs_metadir_update *upd) { @@ -236,7 +236,7 @@ out_teardown: * a negative error code. If an inode is passed back, the caller must finish * setting up the inode before releasing it. */ -int +static int xfs_metadir_create( struct xfs_metadir_update *upd, umode_t mode) @@ -425,7 +425,7 @@ xfs_metadir_commit( } /* Cancel a metadir update and unlock/drop all resources. */ -void +static void xfs_metadir_cancel( struct xfs_metadir_update *upd, int error) @@ -438,48 +438,64 @@ xfs_metadir_cancel( xfs_metadir_teardown(upd, error); } -/* Create a metadata for the last component of the path. */ int -xfs_metadir_mkdir( - struct xfs_inode *dp, - const char *path, +xfs_metadir_create_file( + struct xfs_metadir_update *upd, + umode_t mode, + xfs_metadir_createfn create, + void *priv, struct xfs_inode **ipp) { - struct xfs_metadir_update upd = { - .dp = dp, - .path = path, - .metafile_type = XFS_METAFILE_DIR, - }; int error; - if (xfs_is_shutdown(dp->i_mount)) + if (xfs_is_shutdown(upd->dp->i_mount)) return -EIO; - /* Allocate a transaction to create the last directory. */ - error = xfs_metadir_start_create(&upd); + error = xfs_metadir_start_create(upd); if (error) return error; - /* Create the subdirectory and take our reference. */ - error = xfs_metadir_create(&upd, S_IFDIR); + error = xfs_metadir_create(upd, mode); if (error) goto out_cancel; - error = xfs_metadir_commit(&upd); + if (create) { + error = create(upd, priv); + if (error) + goto out_cancel; + } + + error = xfs_metadir_commit(upd); if (error) goto out_irele; - xfs_finish_inode_setup(upd.ip); - *ipp = upd.ip; + xfs_finish_inode_setup(upd->ip); + *ipp = upd->ip; return 0; out_cancel: - xfs_metadir_cancel(&upd, error); + xfs_metadir_cancel(upd, error); out_irele: /* Have to finish setting up the inode to ensure it's deleted. */ - if (upd.ip) { - xfs_finish_inode_setup(upd.ip); - xfs_irele(upd.ip); + if (upd->ip) { + xfs_finish_inode_setup(upd->ip); + xfs_irele(upd->ip); } return error; } + +/* Create a metadata for the last component of the path. */ +int +xfs_metadir_mkdir( + struct xfs_inode *dp, + const char *path, + struct xfs_inode **ipp) +{ + struct xfs_metadir_update upd = { + .dp = dp, + .path = path, + .metafile_type = XFS_METAFILE_DIR, + }; + + return xfs_metadir_create_file(&upd, S_IFDIR, NULL, NULL, ipp); +} |
