* [PATCH 0/2] *** Code cleanup ***
@ 2025-02-28 8:26 Julian Sun
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
2025-02-28 8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
0 siblings, 2 replies; 8+ messages in thread
From: Julian Sun @ 2025-02-28 8:26 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, Julian Sun
Julian Sun (2):
xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
xfs: refactor out xfs_buf_get_maps()
fs/xfs/libxfs/xfs_da_btree.c | 4 ----
fs/xfs/libxfs/xfs_dir2.c | 8 --------
fs/xfs/xfs_buf.c | 15 +++------------
fs/xfs/xfs_mru_cache.c | 6 ------
fs/xfs/xfs_super.c | 2 --
5 files changed, 3 insertions(+), 32 deletions(-)
--
2.39.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
2025-02-28 8:26 [PATCH 0/2] *** Code cleanup *** Julian Sun
@ 2025-02-28 8:26 ` Julian Sun
2025-03-01 10:20 ` kernel test robot
` (2 more replies)
2025-02-28 8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
1 sibling, 3 replies; 8+ messages in thread
From: Julian Sun @ 2025-02-28 8:26 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, Julian Sun
The __GFP_NOFAIL flag ensures that allocation will not fail.
So remove the unnecessary checks.
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
fs/xfs/libxfs/xfs_da_btree.c | 4 ----
fs/xfs/libxfs/xfs_dir2.c | 8 --------
fs/xfs/xfs_buf.c | 4 ----
fs/xfs/xfs_mru_cache.c | 6 ------
fs/xfs/xfs_super.c | 2 --
5 files changed, 24 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 17d9e6154f19..d4c6ad6be5e1 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -2718,10 +2718,6 @@ xfs_dabuf_map(
if (nirecs > 1) {
map = kzalloc(nirecs * sizeof(struct xfs_buf_map),
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
- if (!map) {
- error = -ENOMEM;
- goto out_free_irecs;
- }
*mapp = map;
}
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c
index 1775abcfa04d..7d837510dc3b 100644
--- a/fs/xfs/libxfs/xfs_dir2.c
+++ b/fs/xfs/libxfs/xfs_dir2.c
@@ -249,8 +249,6 @@ xfs_dir_init(
return error;
args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
- if (!args)
- return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo;
args->dp = dp;
@@ -342,8 +340,6 @@ xfs_dir_createname(
}
args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
- if (!args)
- return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo;
args->name = name->name;
@@ -504,8 +500,6 @@ xfs_dir_removename(
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
- if (!args)
- return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo;
args->name = name->name;
@@ -564,8 +558,6 @@ xfs_dir_replace(
return rval;
args = kzalloc(sizeof(*args), GFP_KERNEL | __GFP_NOFAIL);
- if (!args)
- return -ENOMEM;
args->geo = dp->i_mount->m_dir_geo;
args->name = name->name;
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 15bb790359f8..4b53dde32689 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -182,8 +182,6 @@ xfs_buf_get_maps(
bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map),
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
- if (!bp->b_maps)
- return -ENOMEM;
return 0;
}
@@ -326,8 +324,6 @@ xfs_buf_alloc_kmem(
gfp_mask |= __GFP_ZERO;
bp->b_addr = kmalloc(size, gfp_mask);
- if (!bp->b_addr)
- return -ENOMEM;
if (((unsigned long)(bp->b_addr + size - 1) & PAGE_MASK) !=
((unsigned long)bp->b_addr & PAGE_MASK)) {
diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c
index d0f5b403bdbe..0d08d6b5e5be 100644
--- a/fs/xfs/xfs_mru_cache.c
+++ b/fs/xfs/xfs_mru_cache.c
@@ -333,17 +333,11 @@ xfs_mru_cache_create(
return -EINVAL;
mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL);
- if (!mru)
- return -ENOMEM;
/* An extra list is needed to avoid reaping up to a grp_time early. */
mru->grp_count = grp_count + 1;
mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
GFP_KERNEL | __GFP_NOFAIL);
- if (!mru->lists) {
- err = -ENOMEM;
- goto exit;
- }
for (grp = 0; grp < mru->grp_count; grp++)
INIT_LIST_HEAD(mru->lists + grp);
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 0055066fb1d9..59a600d8de7c 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -2075,8 +2075,6 @@ xfs_init_fs_context(
int i;
mp = kzalloc(sizeof(struct xfs_mount), GFP_KERNEL | __GFP_NOFAIL);
- if (!mp)
- return -ENOMEM;
spin_lock_init(&mp->m_sb_lock);
for (i = 0; i < XG_TYPE_MAX; i++)
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] xfs: refactor out xfs_buf_get_maps()
2025-02-28 8:26 [PATCH 0/2] *** Code cleanup *** Julian Sun
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
@ 2025-02-28 8:26 ` Julian Sun
2025-03-01 11:55 ` kernel test robot
2025-03-04 13:58 ` Christoph Hellwig
1 sibling, 2 replies; 8+ messages in thread
From: Julian Sun @ 2025-02-28 8:26 UTC (permalink / raw)
To: linux-xfs; +Cc: cem, djwong, Julian Sun
Since xfs_buf_get_maps() now always returns 0, we can change
its return type to void, so callers no longer need to check for errors.
Signed-off-by: Julian Sun <sunjunchao2870@gmail.com>
---
fs/xfs/xfs_buf.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 4b53dde32689..adb9a84b86fc 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -167,7 +167,7 @@ xfs_buf_stale(
spin_unlock(&bp->b_lock);
}
-static int
+static void
xfs_buf_get_maps(
struct xfs_buf *bp,
int map_count)
@@ -177,12 +177,11 @@ xfs_buf_get_maps(
if (map_count == 1) {
bp->b_maps = &bp->__b_map;
- return 0;
+ return;
}
bp->b_maps = kzalloc(map_count * sizeof(struct xfs_buf_map),
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
- return 0;
}
static void
@@ -236,11 +235,7 @@ _xfs_buf_alloc(
bp->b_mount = target->bt_mount;
bp->b_flags = flags;
- error = xfs_buf_get_maps(bp, nmaps);
- if (error) {
- kmem_cache_free(xfs_buf_cache, bp);
- return error;
- }
+ xfs_buf_get_maps(bp, nmaps);
bp->b_rhash_key = map[0].bm_bn;
bp->b_length = 0;
--
2.39.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
@ 2025-03-01 10:20 ` kernel test robot
2025-03-06 15:31 ` kernel test robot
2025-03-07 13:58 ` Dan Carpenter
2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-03-01 10:20 UTC (permalink / raw)
To: Julian Sun, linux-xfs; +Cc: llvm, oe-kbuild-all, cem, djwong, Julian Sun
Hi Julian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on linus/master v6.14-rc4 next-20250228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Julian-Sun/xfs-remove-unnecessary-checks-for-__GFP_NOFAIL-allocation/20250228-162815
base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
patch link: https://lore.kernel.org/r/20250228082622.2638686-2-sunjunchao2870%40gmail.com
patch subject: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
config: i386-buildonly-randconfig-001-20250301 (https://download.01.org/0day-ci/archive/20250301/202503011738.qvNVWziu-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250301/202503011738.qvNVWziu-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503011738.qvNVWziu-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/xfs/xfs_mru_cache.c:359:1: warning: unused label 'exit' [-Wunused-label]
359 | exit:
| ^~~~~
1 warning generated.
vim +/exit +359 fs/xfs/xfs_mru_cache.c
2a82b8be8a8dac David Chinner 2007-07-11 307
2a82b8be8a8dac David Chinner 2007-07-11 308 /*
2a82b8be8a8dac David Chinner 2007-07-11 309 * To initialise a struct xfs_mru_cache pointer, call xfs_mru_cache_create()
2a82b8be8a8dac David Chinner 2007-07-11 310 * with the address of the pointer, a lifetime value in milliseconds, a group
2a82b8be8a8dac David Chinner 2007-07-11 311 * count and a free function to use when deleting elements. This function
2a82b8be8a8dac David Chinner 2007-07-11 312 * returns 0 if the initialisation was successful.
2a82b8be8a8dac David Chinner 2007-07-11 313 */
2a82b8be8a8dac David Chinner 2007-07-11 314 int
2a82b8be8a8dac David Chinner 2007-07-11 315 xfs_mru_cache_create(
22328d712dd7fd Christoph Hellwig 2014-04-23 316 struct xfs_mru_cache **mrup,
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 317 void *data,
2a82b8be8a8dac David Chinner 2007-07-11 318 unsigned int lifetime_ms,
2a82b8be8a8dac David Chinner 2007-07-11 319 unsigned int grp_count,
2a82b8be8a8dac David Chinner 2007-07-11 320 xfs_mru_cache_free_func_t free_func)
2a82b8be8a8dac David Chinner 2007-07-11 321 {
22328d712dd7fd Christoph Hellwig 2014-04-23 322 struct xfs_mru_cache *mru = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 323 int err = 0, grp;
2a82b8be8a8dac David Chinner 2007-07-11 324 unsigned int grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 325
2a82b8be8a8dac David Chinner 2007-07-11 326 if (mrup)
2a82b8be8a8dac David Chinner 2007-07-11 327 *mrup = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 328
2a82b8be8a8dac David Chinner 2007-07-11 329 if (!mrup || !grp_count || !lifetime_ms || !free_func)
2451337dd04390 Dave Chinner 2014-06-25 330 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 331
2a82b8be8a8dac David Chinner 2007-07-11 332 if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count))
2451337dd04390 Dave Chinner 2014-06-25 333 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 334
10634530f7ba94 Dave Chinner 2024-01-16 335 mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 336
2a82b8be8a8dac David Chinner 2007-07-11 337 /* An extra list is needed to avoid reaping up to a grp_time early. */
2a82b8be8a8dac David Chinner 2007-07-11 338 mru->grp_count = grp_count + 1;
10634530f7ba94 Dave Chinner 2024-01-16 339 mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
10634530f7ba94 Dave Chinner 2024-01-16 340 GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 341
2a82b8be8a8dac David Chinner 2007-07-11 342 for (grp = 0; grp < mru->grp_count; grp++)
2a82b8be8a8dac David Chinner 2007-07-11 343 INIT_LIST_HEAD(mru->lists + grp);
2a82b8be8a8dac David Chinner 2007-07-11 344
2a82b8be8a8dac David Chinner 2007-07-11 345 /*
2a82b8be8a8dac David Chinner 2007-07-11 346 * We use GFP_KERNEL radix tree preload and do inserts under a
2a82b8be8a8dac David Chinner 2007-07-11 347 * spinlock so GFP_ATOMIC is appropriate for the radix tree itself.
2a82b8be8a8dac David Chinner 2007-07-11 348 */
2a82b8be8a8dac David Chinner 2007-07-11 349 INIT_RADIX_TREE(&mru->store, GFP_ATOMIC);
2a82b8be8a8dac David Chinner 2007-07-11 350 INIT_LIST_HEAD(&mru->reap_list);
007c61c68640ea Eric Sandeen 2007-10-11 351 spin_lock_init(&mru->lock);
2a82b8be8a8dac David Chinner 2007-07-11 352 INIT_DELAYED_WORK(&mru->work, _xfs_mru_cache_reap);
2a82b8be8a8dac David Chinner 2007-07-11 353
2a82b8be8a8dac David Chinner 2007-07-11 354 mru->grp_time = grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 355 mru->free_func = free_func;
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 356 mru->data = data;
2a82b8be8a8dac David Chinner 2007-07-11 357 *mrup = mru;
2a82b8be8a8dac David Chinner 2007-07-11 358
2a82b8be8a8dac David Chinner 2007-07-11 @359 exit:
2a82b8be8a8dac David Chinner 2007-07-11 360 if (err && mru && mru->lists)
d4c75a1b40cd03 Dave Chinner 2024-01-16 361 kfree(mru->lists);
2a82b8be8a8dac David Chinner 2007-07-11 362 if (err && mru)
d4c75a1b40cd03 Dave Chinner 2024-01-16 363 kfree(mru);
2a82b8be8a8dac David Chinner 2007-07-11 364
2a82b8be8a8dac David Chinner 2007-07-11 365 return err;
2a82b8be8a8dac David Chinner 2007-07-11 366 }
2a82b8be8a8dac David Chinner 2007-07-11 367
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xfs: refactor out xfs_buf_get_maps()
2025-02-28 8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
@ 2025-03-01 11:55 ` kernel test robot
2025-03-04 13:58 ` Christoph Hellwig
1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-03-01 11:55 UTC (permalink / raw)
To: Julian Sun, linux-xfs; +Cc: llvm, oe-kbuild-all, cem, djwong, Julian Sun
Hi Julian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on linus/master v6.14-rc4 next-20250228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Julian-Sun/xfs-remove-unnecessary-checks-for-__GFP_NOFAIL-allocation/20250228-162815
base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
patch link: https://lore.kernel.org/r/20250228082622.2638686-3-sunjunchao2870%40gmail.com
patch subject: [PATCH 2/2] xfs: refactor out xfs_buf_get_maps()
config: i386-buildonly-randconfig-001-20250301 (https://download.01.org/0day-ci/archive/20250301/202503011909.oyoVnyss-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250301/202503011909.oyoVnyss-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503011909.oyoVnyss-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> fs/xfs/xfs_buf.c:148:8: warning: unused variable 'error' [-Wunused-variable]
148 | int error;
| ^~~~~
1 warning generated.
vim +/error +148 fs/xfs/xfs_buf.c
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 138
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 139 static int
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 140 _xfs_buf_alloc(
4347b9d7ad4223 fs/xfs/xfs_buf.c Christoph Hellwig 2011-10-10 141 struct xfs_buftarg *target,
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 142 struct xfs_buf_map *map,
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 143 int nmaps,
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 144 xfs_buf_flags_t flags,
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 145 struct xfs_buf **bpp)
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 146 {
4347b9d7ad4223 fs/xfs/xfs_buf.c Christoph Hellwig 2011-10-10 147 struct xfs_buf *bp;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 @148 int error;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 149 int i;
4347b9d7ad4223 fs/xfs/xfs_buf.c Christoph Hellwig 2011-10-10 150
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 151 *bpp = NULL;
0b3a76e955ebe3 fs/xfs/xfs_buf.c Dave Chinner 2024-01-16 152 bp = kmem_cache_zalloc(xfs_buf_cache,
0b3a76e955ebe3 fs/xfs/xfs_buf.c Dave Chinner 2024-01-16 153 GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
4347b9d7ad4223 fs/xfs/xfs_buf.c Christoph Hellwig 2011-10-10 154
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 155 /*
12bcb3f7d4371f fs/xfs/xfs_buf.c Dave Chinner 2012-04-23 156 * We don't want certain flags to appear in b_flags unless they are
12bcb3f7d4371f fs/xfs/xfs_buf.c Dave Chinner 2012-04-23 157 * specifically set by later operations on the buffer.
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 158 */
611c99468c7aa1 fs/xfs/xfs_buf.c Dave Chinner 2012-04-23 159 flags &= ~(XBF_UNMAPPED | XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD);
ce8e922c0e79c8 fs/xfs/linux-2.6/xfs_buf.c Nathan Scott 2006-01-11 160
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 161 /*
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 162 * A new buffer is held and locked by the owner. This ensures that the
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 163 * buffer is owned by the caller and racing RCU lookups right after
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 164 * inserting into the hash table are safe (and will have to wait for
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 165 * the unlock to do anything non-trivial).
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 166 */
ee10f6fcdb961e fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-16 167 bp->b_hold = 1;
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 168 sema_init(&bp->b_sema, 0); /* held, no waiters */
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 169
a9ab28b3d21aec fs/xfs/xfs_buf.c Christoph Hellwig 2025-01-28 170 spin_lock_init(&bp->b_lock);
430cbeb86fdcbb fs/xfs/linux-2.6/xfs_buf.c Dave Chinner 2010-12-02 171 atomic_set(&bp->b_lru_ref, 1);
b4dd330b9e0c9c fs/xfs/linux-2.6/xfs_buf.c David Chinner 2008-08-13 172 init_completion(&bp->b_iowait);
430cbeb86fdcbb fs/xfs/linux-2.6/xfs_buf.c Dave Chinner 2010-12-02 173 INIT_LIST_HEAD(&bp->b_lru);
ce8e922c0e79c8 fs/xfs/linux-2.6/xfs_buf.c Nathan Scott 2006-01-11 174 INIT_LIST_HEAD(&bp->b_list);
643c8c05e75d97 fs/xfs/xfs_buf.c Carlos Maiolino 2018-01-24 175 INIT_LIST_HEAD(&bp->b_li_list);
ce8e922c0e79c8 fs/xfs/linux-2.6/xfs_buf.c Nathan Scott 2006-01-11 176 bp->b_target = target;
dbd329f1e44ed4 fs/xfs/xfs_buf.c Christoph Hellwig 2019-06-28 177 bp->b_mount = target->bt_mount;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 178 bp->b_flags = flags;
de1cbee46269a3 fs/xfs/xfs_buf.c Dave Chinner 2012-04-23 179
5c192f274c0024 fs/xfs/xfs_buf.c Julian Sun 2025-02-28 180 xfs_buf_get_maps(bp, nmaps);
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 181
4c7f65aea7b7fe fs/xfs/xfs_buf.c Dave Chinner 2021-08-18 182 bp->b_rhash_key = map[0].bm_bn;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 183 bp->b_length = 0;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 184 for (i = 0; i < nmaps; i++) {
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 185 bp->b_maps[i].bm_bn = map[i].bm_bn;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 186 bp->b_maps[i].bm_len = map[i].bm_len;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 187 bp->b_length += map[i].bm_len;
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 188 }
3e85c868a69780 fs/xfs/xfs_buf.c Dave Chinner 2012-06-22 189
ce8e922c0e79c8 fs/xfs/linux-2.6/xfs_buf.c Nathan Scott 2006-01-11 190 atomic_set(&bp->b_pin_count, 0);
ce8e922c0e79c8 fs/xfs/linux-2.6/xfs_buf.c Nathan Scott 2006-01-11 191 init_waitqueue_head(&bp->b_waiters);
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 192
dbd329f1e44ed4 fs/xfs/xfs_buf.c Christoph Hellwig 2019-06-28 193 XFS_STATS_INC(bp->b_mount, xb_create);
0b1b213fcf3a84 fs/xfs/linux-2.6/xfs_buf.c Christoph Hellwig 2009-12-14 194 trace_xfs_buf_init(bp, _RET_IP_);
4347b9d7ad4223 fs/xfs/xfs_buf.c Christoph Hellwig 2011-10-10 195
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 196 *bpp = bp;
32dff5e5d1b588 fs/xfs/xfs_buf.c Darrick J. Wong 2020-01-23 197 return 0;
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 198 }
^1da177e4c3f41 fs/xfs/linux-2.6/xfs_buf.c Linus Torvalds 2005-04-16 199
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xfs: refactor out xfs_buf_get_maps()
2025-02-28 8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
2025-03-01 11:55 ` kernel test robot
@ 2025-03-04 13:58 ` Christoph Hellwig
1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2025-03-04 13:58 UTC (permalink / raw)
To: Julian Sun; +Cc: linux-xfs, cem, djwong
On Fri, Feb 28, 2025 at 04:26:22PM +0800, Julian Sun wrote:
> Since xfs_buf_get_maps() now always returns 0, we can change
> its return type to void, so callers no longer need to check for errors.
If we touch this anyway I'd just rather kill xfs_buf_get_maps
entirely.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
2025-03-01 10:20 ` kernel test robot
@ 2025-03-06 15:31 ` kernel test robot
2025-03-07 13:58 ` Dan Carpenter
2 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-03-06 15:31 UTC (permalink / raw)
To: Julian Sun, linux-xfs; +Cc: oe-kbuild-all, cem, djwong, Julian Sun
Hi Julian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on linus/master v6.14-rc5 next-20250306]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Julian-Sun/xfs-remove-unnecessary-checks-for-__GFP_NOFAIL-allocation/20250228-162815
base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
patch link: https://lore.kernel.org/r/20250228082622.2638686-2-sunjunchao2870%40gmail.com
patch subject: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
config: csky-randconfig-002-20250305 (https://download.01.org/0day-ci/archive/20250306/202503062303.aLFvYL6o-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503062303.aLFvYL6o-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503062303.aLFvYL6o-lkp@intel.com/
All warnings (new ones prefixed by >>):
fs/xfs/xfs_mru_cache.c: In function 'xfs_mru_cache_create':
>> fs/xfs/xfs_mru_cache.c:359:1: warning: label 'exit' defined but not used [-Wunused-label]
359 | exit:
| ^~~~
vim +/exit +359 fs/xfs/xfs_mru_cache.c
2a82b8be8a8dac David Chinner 2007-07-11 307
2a82b8be8a8dac David Chinner 2007-07-11 308 /*
2a82b8be8a8dac David Chinner 2007-07-11 309 * To initialise a struct xfs_mru_cache pointer, call xfs_mru_cache_create()
2a82b8be8a8dac David Chinner 2007-07-11 310 * with the address of the pointer, a lifetime value in milliseconds, a group
2a82b8be8a8dac David Chinner 2007-07-11 311 * count and a free function to use when deleting elements. This function
2a82b8be8a8dac David Chinner 2007-07-11 312 * returns 0 if the initialisation was successful.
2a82b8be8a8dac David Chinner 2007-07-11 313 */
2a82b8be8a8dac David Chinner 2007-07-11 314 int
2a82b8be8a8dac David Chinner 2007-07-11 315 xfs_mru_cache_create(
22328d712dd7fd Christoph Hellwig 2014-04-23 316 struct xfs_mru_cache **mrup,
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 317 void *data,
2a82b8be8a8dac David Chinner 2007-07-11 318 unsigned int lifetime_ms,
2a82b8be8a8dac David Chinner 2007-07-11 319 unsigned int grp_count,
2a82b8be8a8dac David Chinner 2007-07-11 320 xfs_mru_cache_free_func_t free_func)
2a82b8be8a8dac David Chinner 2007-07-11 321 {
22328d712dd7fd Christoph Hellwig 2014-04-23 322 struct xfs_mru_cache *mru = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 323 int err = 0, grp;
2a82b8be8a8dac David Chinner 2007-07-11 324 unsigned int grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 325
2a82b8be8a8dac David Chinner 2007-07-11 326 if (mrup)
2a82b8be8a8dac David Chinner 2007-07-11 327 *mrup = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 328
2a82b8be8a8dac David Chinner 2007-07-11 329 if (!mrup || !grp_count || !lifetime_ms || !free_func)
2451337dd04390 Dave Chinner 2014-06-25 330 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 331
2a82b8be8a8dac David Chinner 2007-07-11 332 if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count))
2451337dd04390 Dave Chinner 2014-06-25 333 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 334
10634530f7ba94 Dave Chinner 2024-01-16 335 mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 336
2a82b8be8a8dac David Chinner 2007-07-11 337 /* An extra list is needed to avoid reaping up to a grp_time early. */
2a82b8be8a8dac David Chinner 2007-07-11 338 mru->grp_count = grp_count + 1;
10634530f7ba94 Dave Chinner 2024-01-16 339 mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
10634530f7ba94 Dave Chinner 2024-01-16 340 GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 341
2a82b8be8a8dac David Chinner 2007-07-11 342 for (grp = 0; grp < mru->grp_count; grp++)
2a82b8be8a8dac David Chinner 2007-07-11 343 INIT_LIST_HEAD(mru->lists + grp);
2a82b8be8a8dac David Chinner 2007-07-11 344
2a82b8be8a8dac David Chinner 2007-07-11 345 /*
2a82b8be8a8dac David Chinner 2007-07-11 346 * We use GFP_KERNEL radix tree preload and do inserts under a
2a82b8be8a8dac David Chinner 2007-07-11 347 * spinlock so GFP_ATOMIC is appropriate for the radix tree itself.
2a82b8be8a8dac David Chinner 2007-07-11 348 */
2a82b8be8a8dac David Chinner 2007-07-11 349 INIT_RADIX_TREE(&mru->store, GFP_ATOMIC);
2a82b8be8a8dac David Chinner 2007-07-11 350 INIT_LIST_HEAD(&mru->reap_list);
007c61c68640ea Eric Sandeen 2007-10-11 351 spin_lock_init(&mru->lock);
2a82b8be8a8dac David Chinner 2007-07-11 352 INIT_DELAYED_WORK(&mru->work, _xfs_mru_cache_reap);
2a82b8be8a8dac David Chinner 2007-07-11 353
2a82b8be8a8dac David Chinner 2007-07-11 354 mru->grp_time = grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 355 mru->free_func = free_func;
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 356 mru->data = data;
2a82b8be8a8dac David Chinner 2007-07-11 357 *mrup = mru;
2a82b8be8a8dac David Chinner 2007-07-11 358
2a82b8be8a8dac David Chinner 2007-07-11 @359 exit:
2a82b8be8a8dac David Chinner 2007-07-11 360 if (err && mru && mru->lists)
d4c75a1b40cd03 Dave Chinner 2024-01-16 361 kfree(mru->lists);
2a82b8be8a8dac David Chinner 2007-07-11 362 if (err && mru)
d4c75a1b40cd03 Dave Chinner 2024-01-16 363 kfree(mru);
2a82b8be8a8dac David Chinner 2007-07-11 364
2a82b8be8a8dac David Chinner 2007-07-11 365 return err;
2a82b8be8a8dac David Chinner 2007-07-11 366 }
2a82b8be8a8dac David Chinner 2007-07-11 367
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
2025-03-01 10:20 ` kernel test robot
2025-03-06 15:31 ` kernel test robot
@ 2025-03-07 13:58 ` Dan Carpenter
2 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2025-03-07 13:58 UTC (permalink / raw)
To: oe-kbuild, Julian Sun, linux-xfs
Cc: lkp, oe-kbuild-all, cem, djwong, Julian Sun
Hi Julian,
kernel test robot noticed the following build warnings:
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Julian-Sun/xfs-remove-unnecessary-checks-for-__GFP_NOFAIL-allocation/20250228-162815
base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next
patch link: https://lore.kernel.org/r/20250228082622.2638686-2-sunjunchao2870%40gmail.com
patch subject: [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation.
config: sh-randconfig-r073-20250307 (https://download.01.org/0day-ci/archive/20250307/202503072035.d6QqiZWT-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 14.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202503072035.d6QqiZWT-lkp@intel.com/
New smatch warnings:
fs/xfs/xfs_mru_cache.c:360 xfs_mru_cache_create() warn: variable dereferenced before check 'mru' (see line 338)
vim +/mru +360 fs/xfs/xfs_mru_cache.c
2a82b8be8a8dac David Chinner 2007-07-11 314 int
2a82b8be8a8dac David Chinner 2007-07-11 315 xfs_mru_cache_create(
22328d712dd7fd Christoph Hellwig 2014-04-23 316 struct xfs_mru_cache **mrup,
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 317 void *data,
2a82b8be8a8dac David Chinner 2007-07-11 318 unsigned int lifetime_ms,
2a82b8be8a8dac David Chinner 2007-07-11 319 unsigned int grp_count,
2a82b8be8a8dac David Chinner 2007-07-11 320 xfs_mru_cache_free_func_t free_func)
2a82b8be8a8dac David Chinner 2007-07-11 321 {
22328d712dd7fd Christoph Hellwig 2014-04-23 322 struct xfs_mru_cache *mru = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 323 int err = 0, grp;
2a82b8be8a8dac David Chinner 2007-07-11 324 unsigned int grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 325
2a82b8be8a8dac David Chinner 2007-07-11 326 if (mrup)
2a82b8be8a8dac David Chinner 2007-07-11 327 *mrup = NULL;
2a82b8be8a8dac David Chinner 2007-07-11 328
2a82b8be8a8dac David Chinner 2007-07-11 329 if (!mrup || !grp_count || !lifetime_ms || !free_func)
2451337dd04390 Dave Chinner 2014-06-25 330 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 331
2a82b8be8a8dac David Chinner 2007-07-11 332 if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count))
2451337dd04390 Dave Chinner 2014-06-25 333 return -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 334
10634530f7ba94 Dave Chinner 2024-01-16 335 mru = kzalloc(sizeof(*mru), GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 336
2a82b8be8a8dac David Chinner 2007-07-11 337 /* An extra list is needed to avoid reaping up to a grp_time early. */
2a82b8be8a8dac David Chinner 2007-07-11 @338 mru->grp_count = grp_count + 1;
10634530f7ba94 Dave Chinner 2024-01-16 339 mru->lists = kzalloc(mru->grp_count * sizeof(*mru->lists),
10634530f7ba94 Dave Chinner 2024-01-16 340 GFP_KERNEL | __GFP_NOFAIL);
2a82b8be8a8dac David Chinner 2007-07-11 341
2a82b8be8a8dac David Chinner 2007-07-11 342 for (grp = 0; grp < mru->grp_count; grp++)
2a82b8be8a8dac David Chinner 2007-07-11 343 INIT_LIST_HEAD(mru->lists + grp);
2a82b8be8a8dac David Chinner 2007-07-11 344
2a82b8be8a8dac David Chinner 2007-07-11 345 /*
2a82b8be8a8dac David Chinner 2007-07-11 346 * We use GFP_KERNEL radix tree preload and do inserts under a
2a82b8be8a8dac David Chinner 2007-07-11 347 * spinlock so GFP_ATOMIC is appropriate for the radix tree itself.
2a82b8be8a8dac David Chinner 2007-07-11 348 */
2a82b8be8a8dac David Chinner 2007-07-11 349 INIT_RADIX_TREE(&mru->store, GFP_ATOMIC);
2a82b8be8a8dac David Chinner 2007-07-11 350 INIT_LIST_HEAD(&mru->reap_list);
007c61c68640ea Eric Sandeen 2007-10-11 351 spin_lock_init(&mru->lock);
2a82b8be8a8dac David Chinner 2007-07-11 352 INIT_DELAYED_WORK(&mru->work, _xfs_mru_cache_reap);
2a82b8be8a8dac David Chinner 2007-07-11 353
2a82b8be8a8dac David Chinner 2007-07-11 354 mru->grp_time = grp_time;
2a82b8be8a8dac David Chinner 2007-07-11 355 mru->free_func = free_func;
7fcd3efa1e9ebe Christoph Hellwig 2018-04-09 356 mru->data = data;
2a82b8be8a8dac David Chinner 2007-07-11 357 *mrup = mru;
2a82b8be8a8dac David Chinner 2007-07-11 358
2a82b8be8a8dac David Chinner 2007-07-11 359 exit:
2a82b8be8a8dac David Chinner 2007-07-11 @360 if (err && mru && mru->lists)
^^^
d4c75a1b40cd03 Dave Chinner 2024-01-16 361 kfree(mru->lists);
2a82b8be8a8dac David Chinner 2007-07-11 362 if (err && mru)
^^^
I normally wouldn't hit forward on this zero-day bot thing because it's
obviously harmless. But since you're removing NULL checks you could
remove these two too if you want.
d4c75a1b40cd03 Dave Chinner 2024-01-16 363 kfree(mru);
2a82b8be8a8dac David Chinner 2007-07-11 364
2a82b8be8a8dac David Chinner 2007-07-11 365 return err;
2a82b8be8a8dac David Chinner 2007-07-11 366 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-03-07 13:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-28 8:26 [PATCH 0/2] *** Code cleanup *** Julian Sun
2025-02-28 8:26 ` [PATCH 1/2] xfs: remove unnecessary checks for __GFP_NOFAIL allocation Julian Sun
2025-03-01 10:20 ` kernel test robot
2025-03-06 15:31 ` kernel test robot
2025-03-07 13:58 ` Dan Carpenter
2025-02-28 8:26 ` [PATCH 2/2] xfs: refactor out xfs_buf_get_maps() Julian Sun
2025-03-01 11:55 ` kernel test robot
2025-03-04 13:58 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox