Skip to contentSkip to conversation

f2fs: convert to use sysfs_emit

PATCH In review Yangtao Li 3 participants 4 messages Mar 31, 2023 – Apr 7, 2023 F2FS file system

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 f2fs: convert to use sysfs_emit

Let's use sysfs_emit.

---
 fs/f2fs/sysfs.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
fs/f2fs/sysfs.c +2 -8
index 9ddc6ee19433..2c0b2cb05a3a 100644
@@ -312,19 +312,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
 
 	if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
 		struct ckpt_req_control *cprc = &sbi->cprc_info;
-		int len = 0;
 		int class = IOPRIO_PRIO_CLASS(cprc->ckpt_thread_ioprio);
 		int data = IOPRIO_PRIO_DATA(cprc->ckpt_thread_ioprio);
 
-		if (class == IOPRIO_CLASS_RT)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "rt,");
-		else if (class == IOPRIO_CLASS_BE)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "be,");
-		else
+		if (class != IOPRIO_CLASS_RT && class != IOPRIO_CLASS_BE)
 			return -EINVAL;
 
-		len += scnprintf(buf + len, PAGE_SIZE - len, "%d\n", data);
-		return len;
+		return sysfs_emit(buf, "%s,%d\n", class == IOPRIO_CLASS_RT ? "rt" : "be", data);
 	}
 
 #ifdef CONFIG_F2FS_FS_COMPRESSION
Signature · 8 lines
2.35.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
maintainer
#1 lore raw
Quoted 20 lines · Yangtao Li

Let's use sysfs_emit.

---
  fs/f2fs/sysfs.c | 10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)
fs/f2fs/sysfs.c +0 -2
index 9ddc6ee19433..2c0b2cb05a3a 100644
@@ -312,19 +312,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
 
  	if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
  		struct ckpt_req_control *cprc = &sbi->cprc_info;
-		int len = 0;
  		int class = IOPRIO_PRIO_CLASS(cprc->ckpt_thread_ioprio);
  		int data = IOPRIO_PRIO_DATA(cprc->ckpt_thread_ioprio);
 
-		if (class == IOPRIO_CLASS_RT)

fs/f2fs/sysfs.c static ssize_t f2fs_sbi_show(struct f2fs_attr *a, · line 321

Quoted 10 lines
fs/f2fs/sysfs.c +2 -6
-			len += scnprintf(buf + len, PAGE_SIZE - len, "rt,");
-		else if (class == IOPRIO_CLASS_BE)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "be,");
-		else
+		if (class != IOPRIO_CLASS_RT && class != IOPRIO_CLASS_BE)
  			return -EINVAL;
 
-		len += scnprintf(buf + len, PAGE_SIZE - len, "%d\n", data);
-		return len;
+		return sysfs_emit(buf, "%s,%d\n", class == IOPRIO_CLASS_RT ? "rt" : "be", data);

Exceed 80 columns.

Thanks,

Quoted 3 lines
fs/f2fs/sysfs.c +0 -0
  	}
 
  #ifdef CONFIG_F2FS_FS_COMPRESSION
maintainer
#2 lore raw
Quoted 22 lines · Chao Yu
Quoted 21 lines · Yangtao Li

Let's use sysfs_emit.

---
  fs/f2fs/sysfs.c | 10 ++--------
  1 file changed, 2 insertions(+), 8 deletions(-)
fs/f2fs/sysfs.c +0 -5
index 9ddc6ee19433..2c0b2cb05a3a 100644
@@ -312,19 +312,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
  	if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
  		struct ckpt_req_control *cprc = &sbi->cprc_info;
-		int len = 0;
  		int class = IOPRIO_PRIO_CLASS(cprc->ckpt_thread_ioprio);
  		int data = IOPRIO_PRIO_DATA(cprc->ckpt_thread_ioprio);
-		if (class == IOPRIO_CLASS_RT)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "rt,");
-		else if (class == IOPRIO_CLASS_BE)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "be,");
Quoted 8 lines

fs/f2fs/sysfs.c static ssize_t f2fs_sbi_show(struct f2fs_attr *a, · line 321

Quoted 6 lines
fs/f2fs/sysfs.c +2 -3
-		else
+		if (class != IOPRIO_CLASS_RT && class != IOPRIO_CLASS_BE)
  			return -EINVAL;
-		len += scnprintf(buf + len, PAGE_SIZE - len, "%d\n", data);
-		return len;
+		return sysfs_emit(buf, "%s,%d\n", class == IOPRIO_CLASS_RT ? "rt" : "be", data);

Exceed 80 columns.

Fixed and applied.

Quoted 5 lines

Thanks,

Quoted 2 lines
fs/f2fs/sysfs.c +0 -0
  	}
  #ifdef CONFIG_F2FS_FS_COMPRESSION
maintainer Reviewed-by
#3 lore raw
Quoted 32 lines · Jaegeuk Kim
Quoted 22 lines · Chao Yu
Quoted 21 lines · Yangtao Li

Let's use sysfs_emit.

---
   fs/f2fs/sysfs.c | 10 ++--------
   1 file changed, 2 insertions(+), 8 deletions(-)
fs/f2fs/sysfs.c +0 -5
index 9ddc6ee19433..2c0b2cb05a3a 100644
@@ -312,19 +312,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
   	if (!strcmp(a->attr.name, "ckpt_thread_ioprio")) {
   		struct ckpt_req_control *cprc = &sbi->cprc_info;
-		int len = 0;
   		int class = IOPRIO_PRIO_CLASS(cprc->ckpt_thread_ioprio);
   		int data = IOPRIO_PRIO_DATA(cprc->ckpt_thread_ioprio);
-		if (class == IOPRIO_CLASS_RT)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "rt,");
-		else if (class == IOPRIO_CLASS_BE)
-			len += scnprintf(buf + len, PAGE_SIZE - len, "be,");
Quoted 8 lines

fs/f2fs/sysfs.c static ssize_t f2fs_sbi_show(struct f2fs_attr *a, · line 321

Quoted 6 lines
fs/f2fs/sysfs.c +2 -3
-		else
+		if (class != IOPRIO_CLASS_RT && class != IOPRIO_CLASS_BE)
   			return -EINVAL;
-		len += scnprintf(buf + len, PAGE_SIZE - len, "%d\n", data);
-		return len;
+		return sysfs_emit(buf, "%s,%d\n", class == IOPRIO_CLASS_RT ? "rt" : "be", data);

Exceed 80 columns.

Quoted 1 line

Fixed and applied.

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel