From: Zhen Lei <thunder.leizhen@huawei.com>
To: "Darrick J . Wong" <darrick.wong@oracle.com>,
Brian Foster <bfoster@redhat.com>,
linux-xfs <linux-xfs@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Subject: [PATCH 2/2] xfs: remove the extra processing of zero size in xfs_idata_realloc()
Date: Tue, 24 Nov 2020 18:45:31 +0800 [thread overview]
Message-ID: <20201124104531.561-3-thunder.leizhen@huawei.com> (raw)
In-Reply-To: <20201124104531.561-1-thunder.leizhen@huawei.com>
krealloc() does the free operation when the parameter new_size is 0, with
ZERO_SIZE_PTR returned. Because all other places use NULL to check whether
if_data is available or not, so covert it from ZERO_SIZE_PTR to NULL.
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
fs/xfs/libxfs/xfs_inode_fork.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 4e457aea8493..518af4088e79 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -492,13 +492,6 @@ xfs_idata_realloc(
if (byte_diff == 0)
return;
- if (new_size == 0) {
- kmem_free(ifp->if_u1.if_data);
- ifp->if_u1.if_data = NULL;
- ifp->if_bytes = 0;
- return;
- }
-
/*
* For inline data, the underlying buffer must be a multiple of 4 bytes
* in size so that it can be logged and stay on word boundaries.
@@ -510,7 +503,7 @@ xfs_idata_realloc(
WARN(1, "if_data realloc failed\n");
return;
}
- ifp->if_u1.if_data = if_data;
+ ifp->if_u1.if_data = ZERO_OR_NULL_PTR(if_data) ? NULL : if_data;
ifp->if_bytes = new_size;
}
--
2.26.0.106.g9fadedd
next prev parent reply other threads:[~2020-11-24 10:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 10:45 [PATCH 0/2] xfs: check krealloc() return value and simplify code Zhen Lei
2020-11-24 10:45 ` [PATCH 1/2] xfs: check the return value of krealloc() Zhen Lei
2020-11-24 11:51 ` Christoph Hellwig
2020-11-24 12:05 ` Leizhen (ThunderTown)
2020-11-24 10:45 ` Zhen Lei [this message]
2020-11-24 11:52 ` [PATCH 2/2] xfs: remove the extra processing of zero size in xfs_idata_realloc() Christoph Hellwig
2020-11-24 12:05 ` Leizhen (ThunderTown)
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=20201124104531.561-3-thunder.leizhen@huawei.com \
--to=thunder.leizhen@huawei.com \
--cc=bfoster@redhat.com \
--cc=darrick.wong@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--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).