From: "Darrick J. Wong" <djwong@kernel.org>
To: Allison Henderson <allison.henderson@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v1 03/17] xfs: get directory offset when adding directory name
Date: Wed, 29 Jun 2022 11:29:27 -0700 [thread overview]
Message-ID: <YryaB1tjerPFmzKz@magnolia> (raw)
In-Reply-To: <20220611094200.129502-4-allison.henderson@oracle.com>
On Sat, Jun 11, 2022 at 02:41:46AM -0700, Allison Henderson wrote:
> Return the directory offset information when adding an entry to the
> directory.
>
> This offset will be used as the parent pointer offset in xfs_create,
> xfs_symlink, xfs_link and xfs_rename.
>
> [dchinner: forward ported and cleaned up]
> [dchinner: no s-o-b from Mark]
> [bfoster: rebased, use args->geo in dir code]
> [achender: rebased, chaged __uint32_t to xfs_dir2_dataptr_t]
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Pretty straightforward...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
--D
> ---
> fs/xfs/libxfs/xfs_da_btree.h | 1 +
> fs/xfs/libxfs/xfs_dir2.c | 9 +++++++--
> fs/xfs/libxfs/xfs_dir2.h | 2 +-
> fs/xfs/libxfs/xfs_dir2_block.c | 1 +
> fs/xfs/libxfs/xfs_dir2_leaf.c | 2 ++
> fs/xfs/libxfs/xfs_dir2_node.c | 2 ++
> fs/xfs/libxfs/xfs_dir2_sf.c | 2 ++
> fs/xfs/xfs_inode.c | 6 +++---
> fs/xfs/xfs_symlink.c | 3 ++-
> 9 files changed, 21 insertions(+), 7 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h
> index d33b7686a0b3..e07eeecbe8a9 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.h
> +++ b/fs/xfs/libxfs/xfs_da_btree.h
> @@ -79,6 +79,7 @@ typedef struct xfs_da_args {
> int rmtvaluelen2; /* remote attr value length in bytes */
> uint32_t op_flags; /* operation flags */
> enum xfs_dacmp cmpresult; /* name compare result for lookups */
> + xfs_dir2_dataptr_t offset; /* OUT: offset in directory */
> } xfs_da_args_t;
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
> index 3cd51fa3837b..f7f7fa79593f 100644
> --- a/fs/xfs/libxfs/xfs_dir2.c
> +++ b/fs/xfs/libxfs/xfs_dir2.c
> @@ -257,7 +257,8 @@ xfs_dir_createname(
> struct xfs_inode *dp,
> const struct xfs_name *name,
> xfs_ino_t inum, /* new entry inode number */
> - xfs_extlen_t total) /* bmap's total block count */
> + xfs_extlen_t total, /* bmap's total block count */
> + xfs_dir2_dataptr_t *offset) /* OUT entry's dir offset */
> {
> struct xfs_da_args *args;
> int rval;
> @@ -312,6 +313,10 @@ xfs_dir_createname(
> rval = xfs_dir2_node_addname(args);
>
> out_free:
> + /* return the location that this entry was place in the parent inode */
> + if (offset)
> + *offset = args->offset;
> +
> kmem_free(args);
> return rval;
> }
> @@ -550,7 +555,7 @@ xfs_dir_canenter(
> xfs_inode_t *dp,
> struct xfs_name *name) /* name of entry to add */
> {
> - return xfs_dir_createname(tp, dp, name, 0, 0);
> + return xfs_dir_createname(tp, dp, name, 0, 0, NULL);
> }
>
> /*
> diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h
> index b6df3c34b26a..4d1c2570b833 100644
> --- a/fs/xfs/libxfs/xfs_dir2.h
> +++ b/fs/xfs/libxfs/xfs_dir2.h
> @@ -40,7 +40,7 @@ extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
> struct xfs_inode *pdp);
> extern int xfs_dir_createname(struct xfs_trans *tp, struct xfs_inode *dp,
> const struct xfs_name *name, xfs_ino_t inum,
> - xfs_extlen_t tot);
> + xfs_extlen_t tot, xfs_dir2_dataptr_t *offset);
> extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
> const struct xfs_name *name, xfs_ino_t *inum,
> struct xfs_name *ci_name);
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index df0869bba275..85869f604960 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -573,6 +573,7 @@ xfs_dir2_block_addname(
> xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype);
> tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
> *tagp = cpu_to_be16((char *)dep - (char *)hdr);
> + args->offset = xfs_dir2_byte_to_dataptr((char *)dep - (char *)hdr);
> /*
> * Clean up the bestfree array and log the header, tail, and entry.
> */
> diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
> index d9b66306a9a7..bd0c2f963545 100644
> --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
> @@ -865,6 +865,8 @@ xfs_dir2_leaf_addname(
> xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype);
> tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
> *tagp = cpu_to_be16((char *)dep - (char *)hdr);
> + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, use_block,
> + (char *)dep - (char *)hdr);
> /*
> * Need to scan fix up the bestfree table.
> */
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index 7a03aeb9f4c9..5a9513c036b8 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -1974,6 +1974,8 @@ xfs_dir2_node_addname_int(
> xfs_dir2_data_put_ftype(dp->i_mount, dep, args->filetype);
> tagp = xfs_dir2_data_entry_tag_p(dp->i_mount, dep);
> *tagp = cpu_to_be16((char *)dep - (char *)hdr);
> + args->offset = xfs_dir2_db_off_to_dataptr(args->geo, dbno,
> + (char *)dep - (char *)hdr);
> xfs_dir2_data_log_entry(args, dbp, dep);
>
> /* Rescan the freespace and log the data block if needed. */
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index 5a97a87eaa20..c6c06e8ab54b 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -485,6 +485,7 @@ xfs_dir2_sf_addname_easy(
> memcpy(sfep->name, args->name, sfep->namelen);
> xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber);
> xfs_dir2_sf_put_ftype(mp, sfep, args->filetype);
> + args->offset = xfs_dir2_byte_to_dataptr(offset);
>
> /*
> * Update the header and inode.
> @@ -575,6 +576,7 @@ xfs_dir2_sf_addname_hard(
> memcpy(sfep->name, args->name, sfep->namelen);
> xfs_dir2_sf_put_ino(mp, sfp, sfep, args->inumber);
> xfs_dir2_sf_put_ftype(mp, sfep, args->filetype);
> + args->offset = xfs_dir2_byte_to_dataptr(offset);
> sfp->count++;
> if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange)
> sfp->i8count++;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 23b93403a330..05be02f6f62b 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1052,7 +1052,7 @@ xfs_create(
> unlock_dp_on_error = false;
>
> error = xfs_dir_createname(tp, dp, name, ip->i_ino,
> - resblks - XFS_IALLOC_SPACE_RES(mp));
> + resblks - XFS_IALLOC_SPACE_RES(mp), NULL);
> if (error) {
> ASSERT(error != -ENOSPC);
> goto out_trans_cancel;
> @@ -1275,7 +1275,7 @@ xfs_link(
> }
>
> error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino,
> - resblks);
> + resblks, NULL);
> if (error)
> goto error_return;
> xfs_trans_ichgtime(tp, tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> @@ -3294,7 +3294,7 @@ xfs_rename(
> * to account for the ".." reference from the new entry.
> */
> error = xfs_dir_createname(tp, target_dp, target_name,
> - src_ip->i_ino, spaceres);
> + src_ip->i_ino, spaceres, NULL);
> if (error)
> goto out_trans_cancel;
>
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 18f71fc90dd0..c8b252fa98ff 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -314,7 +314,8 @@ xfs_symlink(
> /*
> * Create the directory entry for the symlink.
> */
> - error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
> + error = xfs_dir_createname(tp, dp, link_name,
> + ip->i_ino, resblks, NULL);
> if (error)
> goto out_trans_cancel;
> xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
> --
> 2.25.1
>
next prev parent reply other threads:[~2022-06-29 18:29 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-11 9:41 [PATCH v1 00/17] Return of the Parent Pointers Allison Henderson
2022-06-11 9:41 ` [PATCH v1 01/17] xfs: Add larp state XFS_DAS_CREATE_FORK Allison Henderson
2022-06-15 1:09 ` Dave Chinner
2022-06-15 23:40 ` Alli
2022-06-16 2:08 ` Dave Chinner
2022-06-16 5:32 ` Dave Chinner
2022-06-29 6:33 ` Alli
2022-06-30 0:40 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 02/17] xfs: Hold inode locks in xfs_ialloc Allison Henderson
2022-06-29 18:28 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 03/17] xfs: get directory offset when adding directory name Allison Henderson
2022-06-29 18:29 ` Darrick J. Wong [this message]
2022-06-11 9:41 ` [PATCH v1 04/17] xfs: get directory offset when removing " Allison Henderson
2022-06-29 18:30 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 05/17] xfs: get directory offset when replacing a " Allison Henderson
2022-06-29 18:30 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 06/17] xfs: add parent pointer support to attribute code Allison Henderson
2022-06-29 18:33 ` Darrick J. Wong
2022-06-29 18:58 ` Alli
2022-06-11 9:41 ` [PATCH v1 07/17] xfs: define parent pointer xattr format Allison Henderson
2022-06-29 18:34 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 08/17] xfs: Add xfs_verify_pptr Allison Henderson
2022-06-29 18:35 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 09/17] xfs: extent transaction reservations for parent attributes Allison Henderson
2022-06-16 5:38 ` Dave Chinner
2022-06-18 0:31 ` Alli
2022-06-29 18:37 ` Darrick J. Wong
2022-06-29 19:23 ` Alli
2022-06-11 9:41 ` [PATCH v1 10/17] xfs: parent pointer attribute creation Allison Henderson
2022-06-16 5:49 ` Dave Chinner
2022-06-18 0:32 ` Alli
2022-06-29 18:41 ` Darrick J. Wong
2022-06-30 1:29 ` Alli
2022-06-11 9:41 ` [PATCH v1 11/17] xfs: add parent attributes to link Allison Henderson
2022-06-16 22:39 ` Dave Chinner
2022-06-18 0:32 ` Alli
2022-06-29 18:09 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 12/17] xfs: remove parent pointers in unlink Allison Henderson
2022-06-29 17:35 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 13/17] xfs: Add parent pointers to rename Allison Henderson
2022-06-29 18:02 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 14/17] xfs: Add the parent pointer support to the superblock version 5 Allison Henderson
2022-06-16 6:03 ` Dave Chinner
2022-06-18 0:32 ` Alli
2022-06-20 0:21 ` Dave Chinner
2022-06-29 18:16 ` Darrick J. Wong
2022-06-11 9:41 ` [PATCH v1 15/17] xfs: Add helper function xfs_attr_list_context_init Allison Henderson
2022-06-29 18:42 ` Darrick J. Wong
2022-06-30 1:30 ` Alli
2022-06-11 9:41 ` [PATCH v1 16/17] xfs: Increase XFS_DEFER_OPS_NR_INODES to 4 Allison Henderson
2022-06-16 21:54 ` Dave Chinner
2022-06-18 0:32 ` Alli
2022-06-29 18:43 ` Darrick J. Wong
2022-06-30 1:30 ` Alli
2022-06-11 9:42 ` [PATCH v1 17/17] xfs: Add parent pointer ioctl Allison Henderson
2022-06-29 18:52 ` Darrick J. Wong
2022-06-30 1:30 ` Alli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YryaB1tjerPFmzKz@magnolia \
--to=djwong@kernel.org \
--cc=allison.henderson@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox