* [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size
2025-08-13 19:52 [PATCH v4 0/2] review of v3 loop: use vfs_getattr_nosec() Rajeev Mishra
@ 2025-08-13 19:52 ` Rajeev Mishra
2025-08-14 6:38 ` Yu Kuai
0 siblings, 1 reply; 9+ messages in thread
From: Rajeev Mishra @ 2025-08-13 19:52 UTC (permalink / raw)
To: axboe, yukuai1; +Cc: linux-block, linux-kernel, Rajeev Mishra
- Renamed get_size to lo_calculate_size.
- Merged get_size and get_loop_size logic into lo_calculate_size.
- Updated all callers to use lo_calculate_size.
- Added header to lo_calculate_size.
Signed-off-by: Rajeev Mishra <rajeevm@hpe.com>
---
drivers/block/loop.c | 50 +++++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 29 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 1b6ee91f8eb9..5faf8607dfb2 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -137,30 +137,23 @@ static void loop_global_unlock(struct loop_device *lo, bool global)
static int max_part;
static int part_shift;
-static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
-{
- loff_t loopsize;
-
- /* Compute loopsize in bytes */
- loopsize = i_size_read(file->f_mapping->host);
- if (offset > 0)
- loopsize -= offset;
- /* offset is beyond i_size, weird but possible */
- if (loopsize < 0)
- return 0;
-
- if (sizelimit > 0 && sizelimit < loopsize)
- loopsize = sizelimit;
- /*
- * Unfortunately, if we want to do I/O on the device,
- * the number of 512-byte sectors has to fit into a sector_t.
- */
- return loopsize >> 9;
-}
-
-static loff_t get_loop_size(struct loop_device *lo, struct file *file)
-{
- return get_size(lo->lo_offset, lo->lo_sizelimit, file);
+static loff_t lo_calculate_size(struct loop_device *lo, struct file *file)
+{
+ loff_t loopsize;
+ /* Compute loopsize in bytes */
+ loopsize = i_size_read(file->f_mapping->host);
+ if (lo->lo_offset > 0)
+ loopsize -= lo->lo_offset;
+ /* offset is beyond i_size, weird but possible */
+ if (loopsize < 0)
+ return 0;
+ if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
+ loopsize = lo->lo_sizelimit;
+ /*
+ * Unfortunately, if we want to do I/O on the device,
+ * the number of 512-byte sectors has to fit into a sector_t.
+ */
+ return loopsize >> 9;
}
/*
@@ -569,7 +562,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
error = -EINVAL;
/* size of the new backing store needs to be the same */
- if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
+ if (lo_calculate_size(lo, file) != lo_calculate_size(lo, old_file))
goto out_err;
/*
@@ -1063,7 +1056,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
loop_update_dio(lo);
loop_sysfs_init(lo);
- size = get_loop_size(lo, file);
+ size = lo_calculate_size(lo, file);
loop_set_size(lo, size);
/* Order wrt reading lo_state in loop_validate_file(). */
@@ -1255,8 +1248,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (partscan)
clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
if (!err && size_changed) {
- loff_t new_size = get_size(lo->lo_offset, lo->lo_sizelimit,
- lo->lo_backing_file);
+ loff_t new_size = lo_calculate_size(lo, lo->lo_backing_file);
loop_set_size(lo, new_size);
}
out_unlock:
@@ -1399,7 +1391,7 @@ static int loop_set_capacity(struct loop_device *lo)
if (unlikely(lo->lo_state != Lo_bound))
return -ENXIO;
- size = get_loop_size(lo, lo->lo_backing_file);
+ size = lo_calculate_size(lo, lo->lo_backing_file);
loop_set_size(lo, size);
return 0;
--
2.43.7
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size
2025-08-13 19:52 ` [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
@ 2025-08-14 6:38 ` Yu Kuai
0 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2025-08-14 6:38 UTC (permalink / raw)
To: Rajeev Mishra, axboe, yukuai1; +Cc: linux-block, linux-kernel, yukuai (C)
Hi,
在 2025/08/14 3:52, Rajeev Mishra 写道:
> - Renamed get_size to lo_calculate_size.
> - Merged get_size and get_loop_size logic into lo_calculate_size.
> - Updated all callers to use lo_calculate_size.
> - Added header to lo_calculate_size.
>
> Signed-off-by: Rajeev Mishra <rajeevm@hpe.com>
> ---
> drivers/block/loop.c | 50 +++++++++++++++++++-------------------------
> 1 file changed, 21 insertions(+), 29 deletions(-)
>
This patch has lots of style issues, please run checkpatch and fix
the warnings first.
Thanks,
Kuai
./scripts/checkpatch.pl
0001-loop-Rename-and-merge-get_size-get_loop_size-to-lo_c.patch
WARNING: please, no spaces at the start of a line
#52: FILE: drivers/block/loop.c:142:
+ loff_t loopsize;$
WARNING: please, no spaces at the start of a line
#54: FILE: drivers/block/loop.c:144:
+ loopsize = i_size_read(file->f_mapping->host);$
WARNING: please, no spaces at the start of a line
#55: FILE: drivers/block/loop.c:145:
+ if (lo->lo_offset > 0)$
WARNING: suspect code indent for conditional statements (7, 15)
#55: FILE: drivers/block/loop.c:145:
+ if (lo->lo_offset > 0)
+ loopsize -= lo->lo_offset;
WARNING: please, no spaces at the start of a line
#58: FILE: drivers/block/loop.c:148:
+ if (loopsize < 0)$
WARNING: suspect code indent for conditional statements (7, 15)
#58: FILE: drivers/block/loop.c:148:
+ if (loopsize < 0)
+ return 0;
WARNING: Statements should start on a tabstop
#59: FILE: drivers/block/loop.c:149:
+ return 0;
WARNING: please, no spaces at the start of a line
#60: FILE: drivers/block/loop.c:150:
+ if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)$
WARNING: suspect code indent for conditional statements (7, 15)
#60: FILE: drivers/block/loop.c:150:
+ if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
+ loopsize = lo->lo_sizelimit;
WARNING: please, no spaces at the start of a line
#66: FILE: drivers/block/loop.c:156:
+ return loopsize >> 9;$
total: 0 errors, 10 warnings, 80 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or
--fix-inplace.
0001-loop-Rename-and-merge-get_size-get_loop_size-to-lo_c.patch has
style problems, please review.
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 1b6ee91f8eb9..5faf8607dfb2 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -137,30 +137,23 @@ static void loop_global_unlock(struct loop_device *lo, bool global)
> static int max_part;
> static int part_shift;
>
> -static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
> -{
> - loff_t loopsize;
> -
> - /* Compute loopsize in bytes */
> - loopsize = i_size_read(file->f_mapping->host);
> - if (offset > 0)
> - loopsize -= offset;
> - /* offset is beyond i_size, weird but possible */
> - if (loopsize < 0)
> - return 0;
> -
> - if (sizelimit > 0 && sizelimit < loopsize)
> - loopsize = sizelimit;
> - /*
> - * Unfortunately, if we want to do I/O on the device,
> - * the number of 512-byte sectors has to fit into a sector_t.
> - */
> - return loopsize >> 9;
> -}
> -
> -static loff_t get_loop_size(struct loop_device *lo, struct file *file)
> -{
> - return get_size(lo->lo_offset, lo->lo_sizelimit, file);
> +static loff_t lo_calculate_size(struct loop_device *lo, struct file *file)
> +{
> + loff_t loopsize;
> + /* Compute loopsize in bytes */
> + loopsize = i_size_read(file->f_mapping->host);
> + if (lo->lo_offset > 0)
> + loopsize -= lo->lo_offset;
> + /* offset is beyond i_size, weird but possible */
> + if (loopsize < 0)
> + return 0;
> + if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
> + loopsize = lo->lo_sizelimit;
> + /*
> + * Unfortunately, if we want to do I/O on the device,
> + * the number of 512-byte sectors has to fit into a sector_t.
> + */
> + return loopsize >> 9;
> }
>
> /*
> @@ -569,7 +562,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
> error = -EINVAL;
>
> /* size of the new backing store needs to be the same */
> - if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
> + if (lo_calculate_size(lo, file) != lo_calculate_size(lo, old_file))
> goto out_err;
>
> /*
> @@ -1063,7 +1056,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
> loop_update_dio(lo);
> loop_sysfs_init(lo);
>
> - size = get_loop_size(lo, file);
> + size = lo_calculate_size(lo, file);
> loop_set_size(lo, size);
>
> /* Order wrt reading lo_state in loop_validate_file(). */
> @@ -1255,8 +1248,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
> if (partscan)
> clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
> if (!err && size_changed) {
> - loff_t new_size = get_size(lo->lo_offset, lo->lo_sizelimit,
> - lo->lo_backing_file);
> + loff_t new_size = lo_calculate_size(lo, lo->lo_backing_file);
> loop_set_size(lo, new_size);
> }
> out_unlock:
> @@ -1399,7 +1391,7 @@ static int loop_set_capacity(struct loop_device *lo)
> if (unlikely(lo->lo_state != Lo_bound))
> return -ENXIO;
>
> - size = get_loop_size(lo, lo->lo_backing_file);
> + size = lo_calculate_size(lo, lo->lo_backing_file);
> loop_set_size(lo, size);
>
> return 0;
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size
@ 2025-08-14 19:10 Rajeev Mishra
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Rajeev Mishra @ 2025-08-14 19:10 UTC (permalink / raw)
To: axboe, yukuai1; +Cc: linux-block, linux-kernel, Rajeev Mishra
- Renamed get_size to lo_calculate_size.
- Merged get_size and get_loop_size logic into lo_calculate_size.
- Updated all callers to use lo_calculate_size.
- Added header to lo_calculate_size.
Signed-off-by: Rajeev Mishra <rajeevm@hpe.com>
---
drivers/block/loop.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 1b6ee91f8eb9..0e1b9eb9db10 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -137,20 +137,18 @@ static void loop_global_unlock(struct loop_device *lo, bool global)
static int max_part;
static int part_shift;
-static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
+static loff_t lo_calculate_size(struct loop_device *lo, struct file *file)
{
loff_t loopsize;
-
/* Compute loopsize in bytes */
loopsize = i_size_read(file->f_mapping->host);
- if (offset > 0)
- loopsize -= offset;
+ if (lo->lo_offset > 0)
+ loopsize -= lo->lo_offset;
/* offset is beyond i_size, weird but possible */
if (loopsize < 0)
return 0;
-
- if (sizelimit > 0 && sizelimit < loopsize)
- loopsize = sizelimit;
+ if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize)
+ loopsize = lo->lo_sizelimit;
/*
* Unfortunately, if we want to do I/O on the device,
* the number of 512-byte sectors has to fit into a sector_t.
@@ -158,11 +156,6 @@ static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
return loopsize >> 9;
}
-static loff_t get_loop_size(struct loop_device *lo, struct file *file)
-{
- return get_size(lo->lo_offset, lo->lo_sizelimit, file);
-}
-
/*
* We support direct I/O only if lo_offset is aligned with the logical I/O size
* of backing device, and the logical block size of loop is bigger than that of
@@ -569,7 +562,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev,
error = -EINVAL;
/* size of the new backing store needs to be the same */
- if (get_loop_size(lo, file) != get_loop_size(lo, old_file))
+ if (lo_calculate_size(lo, file) != lo_calculate_size(lo, old_file))
goto out_err;
/*
@@ -1063,7 +1056,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,
loop_update_dio(lo);
loop_sysfs_init(lo);
- size = get_loop_size(lo, file);
+ size = lo_calculate_size(lo, file);
loop_set_size(lo, size);
/* Order wrt reading lo_state in loop_validate_file(). */
@@ -1255,8 +1248,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (partscan)
clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state);
if (!err && size_changed) {
- loff_t new_size = get_size(lo->lo_offset, lo->lo_sizelimit,
- lo->lo_backing_file);
+ loff_t new_size = lo_calculate_size(lo, lo->lo_backing_file);
loop_set_size(lo, new_size);
}
out_unlock:
@@ -1399,7 +1391,7 @@ static int loop_set_capacity(struct loop_device *lo)
if (unlikely(lo->lo_state != Lo_bound))
return -ENXIO;
- size = get_loop_size(lo, lo->lo_backing_file);
+ size = lo_calculate_size(lo, lo->lo_backing_file);
loop_set_size(lo, size);
return 0;
--
2.43.7
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
2025-08-14 19:10 [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
@ 2025-08-14 19:10 ` Rajeev Mishra
2025-08-18 2:30 ` Yu Kuai
2025-08-20 4:55 ` kernel test robot
2025-08-18 2:29 ` [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Yu Kuai
2025-08-18 16:18 ` Jens Axboe
2 siblings, 2 replies; 9+ messages in thread
From: Rajeev Mishra @ 2025-08-14 19:10 UTC (permalink / raw)
To: axboe, yukuai1; +Cc: linux-block, linux-kernel, Rajeev Mishra
- Use vfs_getattr_nosec() instead of i_size_read() in lo_calculate_size.
- Improves accuracy for network/distributed filesystems.
Signed-off-by: Rajeev Mishra <rajeevm@hpe.com>
---
drivers/block/loop.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 0e1b9eb9db10..57263c273f0f 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -139,9 +139,20 @@ static int part_shift;
static loff_t lo_calculate_size(struct loop_device *lo, struct file *file)
{
+ struct kstat stat;
loff_t loopsize;
- /* Compute loopsize in bytes */
- loopsize = i_size_read(file->f_mapping->host);
+ int ret;
+
+ /*
+ * Get the accurate file size. This provides better results than
+ * cached inode data, particularly for network filesystems where
+ * metadata may be stale.
+ */
+ ret = vfs_getattr_nosec(&file->f_path, &stat, STATX_SIZE, 0);
+ if (ret)
+ return 0;
+
+ loopsize = stat.size;
if (lo->lo_offset > 0)
loopsize -= lo->lo_offset;
/* offset is beyond i_size, weird but possible */
--
2.43.7
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size
2025-08-14 19:10 [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
@ 2025-08-18 2:29 ` Yu Kuai
2025-08-18 16:18 ` Jens Axboe
2 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2025-08-18 2:29 UTC (permalink / raw)
To: Rajeev Mishra, axboe, yukuai1; +Cc: linux-block, linux-kernel, yukuai (C)
在 2025/08/15 3:10, Rajeev Mishra 写道:
> - Renamed get_size to lo_calculate_size.
> - Merged get_size and get_loop_size logic into lo_calculate_size.
> - Updated all callers to use lo_calculate_size.
> - Added header to lo_calculate_size.
>
> Signed-off-by: Rajeev Mishra<rajeevm@hpe.com>
> ---
> drivers/block/loop.c | 26 +++++++++-----------------
> 1 file changed, 9 insertions(+), 17 deletions(-)
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
@ 2025-08-18 2:30 ` Yu Kuai
2025-08-20 4:55 ` kernel test robot
1 sibling, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2025-08-18 2:30 UTC (permalink / raw)
To: Rajeev Mishra, axboe, yukuai1; +Cc: linux-block, linux-kernel, yukuai (C)
在 2025/08/15 3:10, Rajeev Mishra 写道:
> - Use vfs_getattr_nosec() instead of i_size_read() in lo_calculate_size.
> - Improves accuracy for network/distributed filesystems.
>
> Signed-off-by: Rajeev Mishra<rajeevm@hpe.com>
> ---
> drivers/block/loop.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size
2025-08-14 19:10 [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
2025-08-18 2:29 ` [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Yu Kuai
@ 2025-08-18 16:18 ` Jens Axboe
2 siblings, 0 replies; 9+ messages in thread
From: Jens Axboe @ 2025-08-18 16:18 UTC (permalink / raw)
To: Rajeev Mishra, yukuai1; +Cc: linux-block, linux-kernel
On 8/14/25 1:10 PM, Rajeev Mishra wrote:
> - Renamed get_size to lo_calculate_size.
> - Merged get_size and get_loop_size logic into lo_calculate_size.
> - Updated all callers to use lo_calculate_size.
> - Added header to lo_calculate_size.
Please write a proper commit message, rather than these itemized
lists. Goes for both patches.
--
Jens Axboe
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
2025-08-18 2:30 ` Yu Kuai
@ 2025-08-20 4:55 ` kernel test robot
2025-08-20 7:17 ` Yu Kuai
1 sibling, 1 reply; 9+ messages in thread
From: kernel test robot @ 2025-08-20 4:55 UTC (permalink / raw)
To: Rajeev Mishra
Cc: oe-lkp, lkp, linux-block, axboe, yukuai1, linux-kernel,
Rajeev Mishra, oliver.sang
Hello,
kernel test robot noticed "xfstests.generic.563.fail" on:
commit: fb455b8a6ac932603a8c0dbb787f8330b0924834 ("[PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size")
url: https://github.com/intel-lab-lkp/linux/commits/Rajeev-Mishra/loop-use-vfs_getattr_nosec-for-accurate-file-size/20250815-031401
base: https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git for-next
patch link: https://lore.kernel.org/all/20250814191004.60340-2-rajeevm@hpe.com/
patch subject: [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
in testcase: xfstests
version: xfstests-x86_64-e1e4a0ea-1_20250714
with following parameters:
disk: 4HDD
fs: ext4
test: generic-563
config: x86_64-rhel-9.4-func
compiler: gcc-12
test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory
(please refer to attached dmesg/kmsg for entire log/backtrace)
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 <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202508200409.b2459c02-lkp@intel.com
2025-08-17 21:02:18 export TEST_DIR=/fs/sda1
2025-08-17 21:02:18 export TEST_DEV=/dev/sda1
2025-08-17 21:02:18 export FSTYP=ext4
2025-08-17 21:02:18 export SCRATCH_MNT=/fs/scratch
2025-08-17 21:02:18 mkdir /fs/scratch -p
2025-08-17 21:02:18 export SCRATCH_DEV=/dev/sda4
2025-08-17 21:02:18 echo generic/563
2025-08-17 21:02:18 ./check -E tests/exclude/ext4 generic/563
FSTYP -- ext4
PLATFORM -- Linux/x86_64 lkp-skl-d03 6.17.0-rc1-00020-gfb455b8a6ac9 #1 SMP PREEMPT_DYNAMIC Mon Aug 18 03:05:49 CST 2025
MKFS_OPTIONS -- -F /dev/sda4
MOUNT_OPTIONS -- -o acl,user_xattr /dev/sda4 /fs/scratch
generic/563 [failed, exit status 1]- output mismatch (see /lkp/benchmarks/xfstests/results//generic/563.out.bad)
--- tests/generic/563.out 2025-07-14 17:48:52.000000000 +0000
+++ /lkp/benchmarks/xfstests/results//generic/563.out.bad 2025-08-17 21:02:31.367411171 +0000
@@ -1,14 +1 @@
QA output created by 563
-read/write
-read is in range
-write is in range
-write -> read/write
-read is in range
-write is in range
...
(Run 'diff -u /lkp/benchmarks/xfstests/tests/generic/563.out /lkp/benchmarks/xfstests/results//generic/563.out.bad' to see the entire diff)
Ran: generic/563
Failures: generic/563
Failed 1 of 1 tests
The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250820/202508200409.b2459c02-lkp@intel.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
2025-08-20 4:55 ` kernel test robot
@ 2025-08-20 7:17 ` Yu Kuai
0 siblings, 0 replies; 9+ messages in thread
From: Yu Kuai @ 2025-08-20 7:17 UTC (permalink / raw)
To: kernel test robot, Rajeev Mishra
Cc: oe-lkp, lkp, linux-block, axboe, yukuai1, linux-kernel,
yukuai (C)
Hi,
在 2025/08/20 12:55, kernel test robot 写道:
>
>
> Hello,
>
> kernel test robot noticed "xfstests.generic.563.fail" on:
>
> commit: fb455b8a6ac932603a8c0dbb787f8330b0924834 ("[PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size")
> url: https://github.com/intel-lab-lkp/linux/commits/Rajeev-Mishra/loop-use-vfs_getattr_nosec-for-accurate-file-size/20250815-031401
> base: https://git.kernel.org/cgit/linux/kernel/git/axboe/linux-block.git for-next
> patch link: https://lore.kernel.org/all/20250814191004.60340-2-rajeevm@hpe.com/
> patch subject: [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size
>
> in testcase: xfstests
> version: xfstests-x86_64-e1e4a0ea-1_20250714
> with following parameters:
>
> disk: 4HDD
> fs: ext4
> test: generic-563
>
>
>
> config: x86_64-rhel-9.4-func
> compiler: gcc-12
> test machine: 4 threads Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz (Skylake) with 32G memory
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>
>
>
> 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 <oliver.sang@intel.com>
> | Closes: https://lore.kernel.org/oe-lkp/202508200409.b2459c02-lkp@intel.com
>
> 2025-08-17 21:02:18 export TEST_DIR=/fs/sda1
> 2025-08-17 21:02:18 export TEST_DEV=/dev/sda1
> 2025-08-17 21:02:18 export FSTYP=ext4
> 2025-08-17 21:02:18 export SCRATCH_MNT=/fs/scratch
> 2025-08-17 21:02:18 mkdir /fs/scratch -p
> 2025-08-17 21:02:18 export SCRATCH_DEV=/dev/sda4
> 2025-08-17 21:02:18 echo generic/563
> 2025-08-17 21:02:18 ./check -E tests/exclude/ext4 generic/563
> FSTYP -- ext4
> PLATFORM -- Linux/x86_64 lkp-skl-d03 6.17.0-rc1-00020-gfb455b8a6ac9 #1 SMP PREEMPT_DYNAMIC Mon Aug 18 03:05:49 CST 2025
> MKFS_OPTIONS -- -F /dev/sda4
> MOUNT_OPTIONS -- -o acl,user_xattr /dev/sda4 /fs/scratch
>
> generic/563 [failed, exit status 1]- output mismatch (see /lkp/benchmarks/xfstests/results//generic/563.out.bad)
> --- tests/generic/563.out 2025-07-14 17:48:52.000000000 +0000
> +++ /lkp/benchmarks/xfstests/results//generic/563.out.bad 2025-08-17 21:02:31.367411171 +0000
> @@ -1,14 +1 @@
> QA output created by 563
> -read/write
> -read is in range
> -write is in range
> -write -> read/write
> -read is in range
> -write is in range
> ...
> (Run 'diff -u /lkp/benchmarks/xfstests/tests/generic/563.out /lkp/benchmarks/xfstests/results//generic/563.out.bad' to see the entire diff)
> Ran: generic/563
> Failures: generic/563
> Failed 1 of 1 tests
>
This can be reporduce with just losetup /dev/loop0 /dev/sda, root cause
is that /dev/sda is from devtmpfs wherer the get_attr method for
is shmem_getattr, hence stat->size will be set to zero.
In vfs_getattr_nosec(), is the inode is block device, bdev_statx will be
called to override the result, however, STATX_SIZE is not handled here,
I feel handle STATX_SIZE in bdev_statx will make sense:
diff --git a/block/bdev.c b/block/bdev.c
index b77ddd12dc06..9672bb6ec4ad 100644
--- a/block/bdev.c
+++ b/block/bdev.c
@@ -1324,6 +1324,9 @@ void bdev_statx(const struct path *path, struct
kstat *stat, u32 request_mask)
if (!bdev)
return;
+ if (request_mask & STATX_SIZE)
+ stat->size = bdev_nr_bytes(bdev);
+
if (request_mask & STATX_DIOALIGN) {
stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
stat->dio_offset_align = bdev_logical_block_size(bdev);
Thanks,
Kuai
>
>
>
> The kernel config and materials to reproduce are available at:
> https://download.01.org/0day-ci/archive/20250820/202508200409.b2459c02-lkp@intel.com
>
>
>
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-08-20 7:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 19:10 [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
2025-08-14 19:10 ` [PATCH v4 2/2] loop: use vfs_getattr_nosec for accurate file size Rajeev Mishra
2025-08-18 2:30 ` Yu Kuai
2025-08-20 4:55 ` kernel test robot
2025-08-20 7:17 ` Yu Kuai
2025-08-18 2:29 ` [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Yu Kuai
2025-08-18 16:18 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2025-08-13 19:52 [PATCH v4 0/2] review of v3 loop: use vfs_getattr_nosec() Rajeev Mishra
2025-08-13 19:52 ` [PATCH v4 1/2] loop: Rename and merge get_size/get_loop_size to lo_calculate_size Rajeev Mishra
2025-08-14 6:38 ` Yu Kuai
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).