From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/6] xfs: refactor attr scrub memory allocation function
Date: Fri, 5 Jul 2019 10:52:11 -0400 [thread overview]
Message-ID: <20190705145211.GF37448@bfoster> (raw)
In-Reply-To: <156158201810.495944.4418480612524937333.stgit@magnolia>
On Wed, Jun 26, 2019 at 01:46:58PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Move the code that allocates memory buffers for the extended attribute
> scrub code into a separate function so we can reduce memory allocations
> in the next patch.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/scrub/attr.c | 33 ++++++++++++++++++++++++---------
> fs/xfs/scrub/attr.h | 2 ++
> 2 files changed, 26 insertions(+), 9 deletions(-)
>
>
> diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> index fd16eb3fa003..c20b6da1db84 100644
> --- a/fs/xfs/scrub/attr.c
> +++ b/fs/xfs/scrub/attr.c
> @@ -31,26 +31,41 @@
> #include <linux/posix_acl_xattr.h>
> #include <linux/xattr.h>
>
> -/* Set us up to scrub an inode's extended attributes. */
> +/* Allocate enough memory to hold an attr value and attr block bitmaps. */
> int
> -xchk_setup_xattr(
> +xchk_setup_xattr_buf(
> struct xfs_scrub *sc,
> - struct xfs_inode *ip)
> + size_t value_size)
> {
> size_t sz;
>
> /*
> - * Allocate the buffer without the inode lock held. We need enough
> - * space to read every xattr value in the file or enough space to
> - * hold three copies of the xattr free space bitmap. (Not both at
> - * the same time.)
> + * We need enough space to read an xattr value from the file or enough
> + * space to hold three copies of the xattr free space bitmap. We don't
> + * need the buffer space for both purposes at the same time.
> */
> - sz = max_t(size_t, XATTR_SIZE_MAX, 3 * sizeof(long) *
> - BITS_TO_LONGS(sc->mp->m_attr_geo->blksize));
> + sz = 3 * sizeof(long) * BITS_TO_LONGS(sc->mp->m_attr_geo->blksize);
> + sz = max_t(size_t, sz, value_size);
> +
> sc->buf = kmem_zalloc_large(sz, KM_SLEEP);
> if (!sc->buf)
> return -ENOMEM;
>
> + return 0;
> +}
> +
> +/* Set us up to scrub an inode's extended attributes. */
> +int
> +xchk_setup_xattr(
> + struct xfs_scrub *sc,
> + struct xfs_inode *ip)
> +{
> + int error;
> +
> + error = xchk_setup_xattr_buf(sc, XATTR_SIZE_MAX);
> + if (error)
> + return error;
> +
> return xchk_setup_inode_contents(sc, ip, 0);
> }
>
> diff --git a/fs/xfs/scrub/attr.h b/fs/xfs/scrub/attr.h
> index 88bb5e29c60c..27e879aeaafc 100644
> --- a/fs/xfs/scrub/attr.h
> +++ b/fs/xfs/scrub/attr.h
> @@ -62,4 +62,6 @@ xchk_xattr_dstmap(
> BITS_TO_LONGS(sc->mp->m_attr_geo->blksize);
> }
>
> +int xchk_setup_xattr_buf(struct xfs_scrub *sc, size_t value_size);
> +
> #endif /* __XFS_SCRUB_ATTR_H__ */
>
next prev parent reply other threads:[~2019-07-05 14:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 20:46 [PATCH v2 0/6] xfs: scrub-related fixes Darrick J. Wong
2019-06-26 20:46 ` [PATCH 1/6] xfs: remove more ondisk directory corruption asserts Darrick J. Wong
2019-07-05 14:49 ` Brian Foster
2019-07-05 17:03 ` Darrick J. Wong
2019-07-05 17:27 ` Brian Foster
2019-06-26 20:46 ` [PATCH 2/6] xfs: attribute scrub should use seen_enough to pass error values Darrick J. Wong
2019-07-05 14:49 ` Brian Foster
2019-07-05 16:46 ` Darrick J. Wong
2019-06-26 20:46 ` [PATCH 3/6] xfs: refactor extended attribute buffer pointer functions Darrick J. Wong
2019-07-05 14:52 ` Brian Foster
2019-06-26 20:46 ` [PATCH 4/6] xfs: refactor attr scrub memory allocation function Darrick J. Wong
2019-07-05 14:52 ` Brian Foster [this message]
2019-06-26 20:47 ` [PATCH 5/6] xfs: only allocate memory for scrubbing attributes when we need it Darrick J. Wong
2019-07-05 14:52 ` Brian Foster
2019-07-05 16:49 ` Darrick J. Wong
2019-06-26 20:47 ` [PATCH 6/6] xfs: online scrub needn't bother zeroing its temporary buffer Darrick J. Wong
2019-07-05 14:52 ` Brian Foster
2019-07-05 16:35 ` Darrick J. Wong
2019-07-05 17:26 ` Brian Foster
2019-07-05 17:57 ` Darrick J. Wong
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=20190705145211.GF37448@bfoster \
--to=bfoster@redhat.com \
--cc=darrick.wong@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).