From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Carlos Maiolino <cmaiolino@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/5] xfs: Remove kmem_realloc
Date: Wed, 20 Nov 2019 11:00:33 -0800 [thread overview]
Message-ID: <20191120190033.GQ6219@magnolia> (raw)
In-Reply-To: <20191120104425.407213-5-cmaiolino@redhat.com>
On Wed, Nov 20, 2019 at 11:44:24AM +0100, Carlos Maiolino wrote:
> We can use krealloc() with __GFP_NOFAIL directly
>
> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> V2:
> - Fix small conflict in kmem.h due removal of kmem_free()
> - Small comment update on xfs_iroot_realloc()
>
> fs/xfs/kmem.c | 22 ----------------------
> fs/xfs/kmem.h | 1 -
> fs/xfs/libxfs/xfs_iext_tree.c | 2 +-
> fs/xfs/libxfs/xfs_inode_fork.c | 10 +++++-----
> fs/xfs/xfs_log_recover.c | 2 +-
> fs/xfs/xfs_mount.c | 4 ++--
> 6 files changed, 9 insertions(+), 32 deletions(-)
>
> diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c
> index 2644fdaa0549..6e10e565632c 100644
> --- a/fs/xfs/kmem.c
> +++ b/fs/xfs/kmem.c
> @@ -93,25 +93,3 @@ kmem_alloc_large(size_t size, xfs_km_flags_t flags)
> return ptr;
> return __kmem_vmalloc(size, flags);
> }
> -
> -void *
> -kmem_realloc(const void *old, size_t newsize, xfs_km_flags_t flags)
> -{
> - int retries = 0;
> - gfp_t lflags = kmem_flags_convert(flags);
> - void *ptr;
> -
> - trace_kmem_realloc(newsize, flags, _RET_IP_);
> -
> - do {
> - ptr = krealloc(old, newsize, lflags);
> - if (ptr || (flags & KM_MAYFAIL))
> - return ptr;
> - if (!(++retries % 100))
> - xfs_err(NULL,
> - "%s(%u) possible memory allocation deadlock size %zu in %s (mode:0x%x)",
> - current->comm, current->pid,
> - newsize, __func__, lflags);
> - congestion_wait(BLK_RW_ASYNC, HZ/50);
> - } while (1);
> -}
> diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
> index b9ee67fa747b..a18c27c99721 100644
> --- a/fs/xfs/kmem.h
> +++ b/fs/xfs/kmem.h
> @@ -55,7 +55,6 @@ kmem_flags_convert(xfs_km_flags_t flags)
> extern void *kmem_alloc(size_t, xfs_km_flags_t);
> extern void *kmem_alloc_io(size_t size, int align_mask, xfs_km_flags_t flags);
> extern void *kmem_alloc_large(size_t size, xfs_km_flags_t);
> -extern void *kmem_realloc(const void *, size_t, xfs_km_flags_t);
>
> static inline void *
> kmem_zalloc_large(size_t size, xfs_km_flags_t flags)
> diff --git a/fs/xfs/libxfs/xfs_iext_tree.c b/fs/xfs/libxfs/xfs_iext_tree.c
> index e75e7c021187..78c9f6c7a36a 100644
> --- a/fs/xfs/libxfs/xfs_iext_tree.c
> +++ b/fs/xfs/libxfs/xfs_iext_tree.c
> @@ -607,7 +607,7 @@ xfs_iext_realloc_root(
> if (new_size / sizeof(struct xfs_iext_rec) == RECS_PER_LEAF)
> new_size = NODE_SIZE;
>
> - new = kmem_realloc(ifp->if_u1.if_root, new_size, KM_NOFS);
> + new = krealloc(ifp->if_u1.if_root, new_size, GFP_NOFS | __GFP_NOFAIL);
> memset(new + ifp->if_bytes, 0, new_size - ifp->if_bytes);
> ifp->if_u1.if_root = new;
> cur->leaf = new;
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index ceb322c7105e..82799dddf97d 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -380,15 +380,15 @@ xfs_iroot_realloc(
>
> /*
> * If there is already an existing if_broot, then we need
> - * to realloc() it and shift the pointers to their new
> + * to krealloc() it and shift the pointers to their new
> * location. The records don't change location because
> * they are kept butted up against the btree block header.
> */
> cur_max = xfs_bmbt_maxrecs(mp, ifp->if_broot_bytes, 0);
> new_max = cur_max + rec_diff;
> new_size = XFS_BMAP_BROOT_SPACE_CALC(mp, new_max);
> - ifp->if_broot = kmem_realloc(ifp->if_broot, new_size,
> - KM_NOFS);
> + ifp->if_broot = krealloc(ifp->if_broot, new_size,
> + GFP_NOFS | __GFP_NOFAIL);
> op = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1,
> ifp->if_broot_bytes);
> np = (char *)XFS_BMAP_BROOT_PTR_ADDR(mp, ifp->if_broot, 1,
> @@ -497,8 +497,8 @@ xfs_idata_realloc(
> * in size so that it can be logged and stay on word boundaries.
> * We enforce that here.
> */
> - ifp->if_u1.if_data = kmem_realloc(ifp->if_u1.if_data,
> - roundup(new_size, 4), KM_NOFS);
> + ifp->if_u1.if_data = krealloc(ifp->if_u1.if_data, roundup(new_size, 4),
> + GFP_NOFS | __GFP_NOFAIL);
> ifp->if_bytes = new_size;
> }
>
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index cb02deb5dedc..5423171e0b7d 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -4211,7 +4211,7 @@ xlog_recover_add_to_cont_trans(
> old_ptr = item->ri_buf[item->ri_cnt-1].i_addr;
> old_len = item->ri_buf[item->ri_cnt-1].i_len;
>
> - ptr = kmem_realloc(old_ptr, len + old_len, 0);
> + ptr = krealloc(old_ptr, len + old_len, GFP_KERNEL | __GFP_NOFAIL);
> memcpy(&ptr[old_len], dp, len);
> item->ri_buf[item->ri_cnt-1].i_len += len;
> item->ri_buf[item->ri_cnt-1].i_addr = ptr;
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index c352567c8ef5..12a1cdf8e292 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -80,9 +80,9 @@ xfs_uuid_mount(
> }
>
> if (hole < 0) {
> - xfs_uuid_table = kmem_realloc(xfs_uuid_table,
> + xfs_uuid_table = krealloc(xfs_uuid_table,
> (xfs_uuid_table_size + 1) * sizeof(*xfs_uuid_table),
> - 0);
> + GFP_KERNEL | __GFP_NOFAIL);
> hole = xfs_uuid_table_size++;
> }
> xfs_uuid_table[hole] = *uuid;
> --
> 2.23.0
>
next prev parent reply other threads:[~2019-11-20 19:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-20 10:44 [PATCH 0/5] Remove/convert more kmem_* wrappers Carlos Maiolino
2019-11-20 10:44 ` [PATCH V2 1/5] xfs: remove kmem_zone_zalloc() Carlos Maiolino
2019-11-20 10:44 ` [PATCH V2 2/5] xfs: Remove kmem_zone_alloc() wrapper Carlos Maiolino
2019-11-20 18:58 ` Darrick J. Wong
2019-11-20 10:44 ` [PATCH 3/5] xfs: remove kmem_zalloc() wrapper Carlos Maiolino
2019-11-20 19:00 ` Darrick J. Wong
2019-11-20 21:24 ` Dave Chinner
2019-11-20 21:41 ` Darrick J. Wong
2019-11-20 22:44 ` Carlos Maiolino
2019-11-20 23:08 ` Darrick J. Wong
2019-11-20 10:44 ` [PATCH 4/5] xfs: Remove kmem_realloc Carlos Maiolino
2019-11-20 19:00 ` Darrick J. Wong [this message]
2019-11-20 10:44 ` [PATCH 5/5] xfs: Convert kmem_alloc() users Carlos Maiolino
2019-11-20 19:00 ` Darrick J. Wong
2019-11-22 15:57 ` Darrick J. Wong
2019-11-22 22:30 ` Darrick J. Wong
2019-11-24 22:02 ` Darrick J. Wong
2019-11-25 9:28 ` Carlos Maiolino
2020-05-14 9:26 ` [PATCH 0/5] Remove/convert more kmem_* wrappers Dave Chinner
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=20191120190033.GQ6219@magnolia \
--to=darrick.wong@oracle.com \
--cc=cmaiolino@redhat.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).