From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Allison Henderson <allison.henderson@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 03/17] Add xfs_attr_set_defered and xfs_attr_remove_defered
Date: Wed, 11 Oct 2017 21:38:09 -0700 [thread overview]
Message-ID: <20171012043809.GE7122@magnolia> (raw)
In-Reply-To: <1507327548-3221-4-git-send-email-allison.henderson@oracle.com>
On Fri, Oct 06, 2017 at 03:05:34PM -0700, Allison Henderson wrote:
Needs changelog... why are we doing this?
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> ---
> :100644 100644 5325ec2... 5c9b604... M fs/xfs/libxfs/xfs_attr.c
> :100644 100644 06c4081... 67b0fbf... M fs/xfs/xfs_attr.h
> fs/xfs/libxfs/xfs_attr.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_attr.h | 5 +++++
> 2 files changed, 63 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 5325ec2..5c9b604 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -458,6 +458,37 @@ xfs_attr_set(
> return error;
> }
>
> +int
> +xfs_attr_set_defered(
"deferred"
> + struct xfs_inode *dp,
> + struct xfs_defer_ops *dfops,
> + const unsigned char *name,
> + int namelen,
> + unsigned char *value,
> + int valuelen,
unsigned int valuelen? I don't see a need for negative lengths. :)
> + int flags)
> +{
> +
> + struct xfs_attr_item *new;
> +
> + ASSERT(name != NULL);
> + ASSERT(value != NULL);
It's probably more valuable to assert on namelen/valuelen because if
these pointers are null we'll crash when get to the memcpy.
> +
> + new = kmem_alloc(sizeof(struct xfs_attr_item), KM_SLEEP);
Hmm. At first I saw the KM_SLEEP and wondered why we'd sleep in
transaction context with an inode (presumably) locked, but xfs_defer_add
does that too. Then again they could both be wrong.
If nothing else we've the inode locked so I think this also needs
KM_NOFS so that we don't recurse into fs reclaim and deadlock trying to
free up memory related to this inode.`
(Same applies to the next function.)
--D
> + memset(new, 0, sizeof(struct xfs_attr_item));
> + new->xattri_ino = dp->i_ino;
> + new->xattri_op_flags = ATTR_OP_FLAGS_SET;
> + new->xattri_name_len = namelen;
> + new->xattri_nameval_len = namelen + valuelen;
> + new->xattri_flags = flags;
> + memcpy(new->xattri_nameval, name, namelen);
> + memcpy(&new->xattri_nameval[namelen], value, valuelen);
> +
> + xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
> +
> + return 0;
> +}
> +
> /*
> * Generic handler routine to remove a name from an attribute list.
> * Transitions attribute list from Btree to shortform as necessary.
> @@ -531,6 +562,33 @@ xfs_attr_remove(
> return error;
> }
>
> +int
> +xfs_attr_remove_defered(
> + struct xfs_inode *dp,
> + struct xfs_defer_ops *dfops,
> + const unsigned char *name,
> + int namelen,
> + int flags)
> +{
> +
> + struct xfs_attr_item *new;
> +
> + ASSERT(name != NULL);
> +
> + new = kmem_alloc(sizeof(struct xfs_attr_item), KM_SLEEP);
> + memset(new, 0, sizeof(struct xfs_attr_item));
> + new->xattri_ino = dp->i_ino;
> + new->xattri_op_flags = ATTR_OP_FLAGS_REMOVE;
> + new->xattri_name_len = namelen;
> + new->xattri_nameval_len = namelen;
> + new->xattri_flags = flags;
> + memcpy(new->xattri_nameval, name, namelen);
> +
> + xfs_defer_add(dfops, XFS_DEFER_OPS_TYPE_ATTR, &new->xattri_list);
> +
> + return 0;
> +}
> +
> /*========================================================================
> * External routines when attribute list is inside the inode
> *========================================================================*/
> diff --git a/fs/xfs/xfs_attr.h b/fs/xfs/xfs_attr.h
> index 06c4081..67b0fbf 100644
> --- a/fs/xfs/xfs_attr.h
> +++ b/fs/xfs/xfs_attr.h
> @@ -176,5 +176,10 @@ int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
> int xfs_attr_args_init(struct xfs_da_args *args, struct xfs_inode *dp,
> const unsigned char *name, int flags);
> int xfs_attr_calc_size(struct xfs_da_args *args, int *local);
> +int xfs_attr_set_defered(struct xfs_inode *dp, struct xfs_defer_ops *dfops,
> + const unsigned char *name, int name_len,
> + unsigned char *value, int valuelen, int flags);
> +int xfs_attr_remove_defered(struct xfs_inode *dp, struct xfs_defer_ops *dfops,
> + const unsigned char *name, int namelen, int flags);
>
> #endif /* __XFS_ATTR_H__ */
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-10-12 4:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 22:05 [PATCH 00/17] Parent Pointers V2 Allison Henderson
2017-10-06 22:05 ` [PATCH 01/17] Add helper functions xfs_attr_set_args and xfs_attr_remove_args Allison Henderson
2017-10-06 22:05 ` [PATCH 02/17] Set up infastructure for deferred attribute operations Allison Henderson
2017-10-09 4:20 ` Dave Chinner
2017-10-09 21:25 ` Allison Henderson
2017-10-09 22:51 ` Allison Henderson
2017-10-09 23:27 ` Dave Chinner
2017-10-06 22:05 ` [PATCH 03/17] Add xfs_attr_set_defered and xfs_attr_remove_defered Allison Henderson
2017-10-12 4:38 ` Darrick J. Wong [this message]
2017-10-06 22:05 ` [PATCH 04/17] Remove all strlen calls in all xfs_attr_* functions for attr names Allison Henderson
2017-10-06 22:05 ` [PATCH 05/17] xfs: get directory offset when adding directory name Allison Henderson
2017-10-06 22:05 ` [PATCH 06/17] xfs: get directory offset when removing " Allison Henderson
2017-10-06 22:05 ` [PATCH 07/17] xfs: get directory offset when replacing a " Allison Henderson
2017-10-06 22:05 ` [PATCH 08/17] xfs: add parent pointer support to attribute code Allison Henderson
2017-10-06 22:05 ` [PATCH 09/17] xfs: define parent pointer xattr format Allison Henderson
2017-10-06 22:05 ` [PATCH 10/17] :xfs: extent transaction reservations for parent attributes Allison Henderson
2017-10-06 22:05 ` [PATCH 11/17] Add the extra space requirements for parent pointer attributes when calculating the minimum log size during mkfs Allison Henderson
2017-10-06 22:05 ` [PATCH 12/17] xfs: parent pointer attribute creation Allison Henderson
2017-10-06 22:05 ` [PATCH 13/17] xfs: add parent attributes to link Allison Henderson
2017-10-06 22:05 ` [PATCH 14/17] xfs: remove parent pointers in unlink Allison Henderson
2017-10-06 22:05 ` [PATCH 15/17] xfs_bmap_add_attrfork(): re-add error handling from set_attrforkoff() call Allison Henderson
2017-10-06 22:05 ` [PATCH 16/17] Add parent pointers to rename Allison Henderson
2017-10-06 22:05 ` [PATCH 17/17] Add the parent pointer support to the superblock version 5 Allison Henderson
-- strict thread matches above, loose matches on Subject: below --
2017-10-18 22:55 [PATCH 00/17] Parent Pointers V3 Allison Henderson
2017-10-18 22:55 ` [PATCH 03/17] Add xfs_attr_set_defered and xfs_attr_remove_defered Allison Henderson
2017-10-19 19:13 ` Darrick J. Wong
2017-10-21 1:08 ` Allison Henderson
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=20171012043809.GE7122@magnolia \
--to=darrick.wong@oracle.com \
--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;
as well as URLs for NNTP newsgroup(s).