linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()
@ 2025-06-20 10:53 Shankari Anand
  2025-06-27  5:49 ` Shankari Anand
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Shankari Anand @ 2025-06-20 10:53 UTC (permalink / raw)
  To: linux-scsi; +Cc: James.Bottomley, martin.petersen, Shankari Anand

Documentation/filesystems/sysfs.rst mentions that show() should only
use sysfs_emit() or sysfs_emit_at() when formating the value to be
returned to user space. So replace scnprintf() with sysfs_emit().

Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
---
 drivers/scsi/scsi_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index d772258e29ad..074b02e4cf9e 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1095,14 +1095,14 @@ sdev_show_blacklist(struct device *dev, struct device_attribute *attr,
 			name = sdev_bflags_name[i];
 
 		if (name)
-			len += scnprintf(buf + len, PAGE_SIZE - len,
+			len += sysfs_emit(buf + len,
 					 "%s%s", len ? " " : "", name);
 		else
-			len += scnprintf(buf + len, PAGE_SIZE - len,
+			len += sysfs_emit(buf + len,
 					 "%sINVALID_BIT(%d)", len ? " " : "", i);
 	}
 	if (len)
-		len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
+		len += sysfs_emit(buf + len, "\n");
 	return len;
 }
 static DEVICE_ATTR(blacklist, S_IRUGO, sdev_show_blacklist, NULL);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()
  2025-06-20 10:53 [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist() Shankari Anand
@ 2025-06-27  5:49 ` Shankari Anand
  2025-06-27 20:53 ` Bart Van Assche
  2025-07-02  6:41 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Shankari Anand @ 2025-06-27  5:49 UTC (permalink / raw)
  To: linux-scsi; +Cc: James.Bottomley, martin.petersen

Hi,
I wanted to kindly follow up and ask if this patch could be picked up
for review. Please let me know if there’s anything I should revise
Thanks!

On Fri, Jun 20, 2025 at 4:23 PM Shankari Anand
<shankari.ak0208@gmail.com> wrote:
>
> Documentation/filesystems/sysfs.rst mentions that show() should only
> use sysfs_emit() or sysfs_emit_at() when formating the value to be
> returned to user space. So replace scnprintf() with sysfs_emit().
>
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> ---
>  drivers/scsi/scsi_sysfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index d772258e29ad..074b02e4cf9e 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1095,14 +1095,14 @@ sdev_show_blacklist(struct device *dev, struct device_attribute *attr,
>                         name = sdev_bflags_name[i];
>
>                 if (name)
> -                       len += scnprintf(buf + len, PAGE_SIZE - len,
> +                       len += sysfs_emit(buf + len,
>                                          "%s%s", len ? " " : "", name);
>                 else
> -                       len += scnprintf(buf + len, PAGE_SIZE - len,
> +                       len += sysfs_emit(buf + len,
>                                          "%sINVALID_BIT(%d)", len ? " " : "", i);
>         }
>         if (len)
> -               len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
> +               len += sysfs_emit(buf + len, "\n");
>         return len;
>  }
>  static DEVICE_ATTR(blacklist, S_IRUGO, sdev_show_blacklist, NULL);
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()
  2025-06-20 10:53 [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist() Shankari Anand
  2025-06-27  5:49 ` Shankari Anand
@ 2025-06-27 20:53 ` Bart Van Assche
  2025-07-02  6:41 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2025-06-27 20:53 UTC (permalink / raw)
  To: Shankari Anand, linux-scsi; +Cc: James.Bottomley, martin.petersen

On 6/20/25 3:53 AM, Shankari Anand wrote:
> Documentation/filesystems/sysfs.rst mentions that show() should only
> use sysfs_emit() or sysfs_emit_at() when formating the value to be
> returned to user space. So replace scnprintf() with sysfs_emit().
> 
> Signed-off-by: Shankari Anand <shankari.ak0208@gmail.com>
> ---
>   drivers/scsi/scsi_sysfs.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index d772258e29ad..074b02e4cf9e 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -1095,14 +1095,14 @@ sdev_show_blacklist(struct device *dev, struct device_attribute *attr,
>   			name = sdev_bflags_name[i];
>   
>   		if (name)
> -			len += scnprintf(buf + len, PAGE_SIZE - len,
> +			len += sysfs_emit(buf + len,
>   					 "%s%s", len ? " " : "", name);
>   		else
> -			len += scnprintf(buf + len, PAGE_SIZE - len,
> +			len += sysfs_emit(buf + len,
>   					 "%sINVALID_BIT(%d)", len ? " " : "", i);
>   	}
>   	if (len)
> -		len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
> +		len += sysfs_emit(buf + len, "\n");
>   	return len;
>   }
>   static DEVICE_ATTR(blacklist, S_IRUGO, sdev_show_blacklist, NULL);

This patch changes correct code into broken code. Hence, to the SCSI
maintainer, please do *not* apply this patch.

Bart.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()
  2025-06-20 10:53 [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist() Shankari Anand
  2025-06-27  5:49 ` Shankari Anand
  2025-06-27 20:53 ` Bart Van Assche
@ 2025-07-02  6:41 ` kernel test robot
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-07-02  6:41 UTC (permalink / raw)
  To: Shankari Anand
  Cc: oe-lkp, lkp, linux-scsi, James.Bottomley, martin.petersen,
	Shankari Anand, oliver.sang


Hello,

kernel test robot noticed "blktests.scsi/005.fail" on:

commit: 2f688d0bc23ecf97b4f5255343dc891b196d1360 ("[PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()")
url: https://github.com/intel-lab-lkp/linux/commits/Shankari-Anand/scsi-sysfs-replace-scnprintf-with-sysfs_emit-in-sdev_show_blacklist/20250620-190212
base: https://git.kernel.org/cgit/linux/kernel/git/jejb/scsi.git for-next
patch link: https://lore.kernel.org/all/20250620105344.455283-1-shankari.ak0208@gmail.com/
patch subject: [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist()

in testcase: blktests
version: blktests-x86_64-55d3d61-1_20250617
with following parameters:

	disk: 1HDD
	test: scsi-005


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/202507020840.90a6d3bd-lkp@intel.com

2025-06-30 16:29:51 echo scsi/005
2025-06-30 16:29:51 ./check scsi/005
scsi/005 (test SCSI device blacklisting)                    
scsi/005 (test SCSI device blacklisting)                     [failed]
    runtime    ...  6.188s
    --- tests/scsi/005.out	2025-06-17 17:08:29.000000000 +0000
    +++ /lkp/benchmarks/blktests/results/nodev/scsi/005.out.bad	2025-06-30 16:29:58.087863341 +0000
    @@ -1,7 +1,7 @@
     Running scsi/005
                               
     AAAAAAAA BBBBBBBBBBBBBBBB 
    -HITACHI  OPEN-V           REPORTLUN2 TRY_VPD_PAGES
    +HITACHI  OPEN-V           REPORTLUN2
              Scanner          NOLUN
     Inateck                   
    ...
    (Run 'diff -u tests/scsi/005.out /lkp/benchmarks/blktests/results/nodev/scsi/005.out.bad' to see the entire diff)



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250702/202507020840.90a6d3bd-lkp@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-02  6:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-20 10:53 [PATCH] scsi: sysfs: replace scnprintf() with sysfs_emit() in sdev_show_blacklist() Shankari Anand
2025-06-27  5:49 ` Shankari Anand
2025-06-27 20:53 ` Bart Van Assche
2025-07-02  6:41 ` kernel test robot

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).