Skip to content

Commit a301b2d

Browse files
ye xingchenaxboe
authored andcommitted
bcache: Convert to use sysfs_emit()/sysfs_emit_at() APIs
Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: ye xingchen <[email protected]> Signed-off-by: Coly Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dd7de37 commit a301b2d

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

drivers/md/bcache/sysfs.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,26 +1111,25 @@ SHOW(__bch_cache)
11111111

11121112
vfree(p);
11131113

1114-
ret = scnprintf(buf, PAGE_SIZE,
1115-
"Unused: %zu%%\n"
1116-
"Clean: %zu%%\n"
1117-
"Dirty: %zu%%\n"
1118-
"Metadata: %zu%%\n"
1119-
"Average: %llu\n"
1120-
"Sectors per Q: %zu\n"
1121-
"Quantiles: [",
1122-
unused * 100 / (size_t) ca->sb.nbuckets,
1123-
available * 100 / (size_t) ca->sb.nbuckets,
1124-
dirty * 100 / (size_t) ca->sb.nbuckets,
1125-
meta * 100 / (size_t) ca->sb.nbuckets, sum,
1126-
n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
1114+
ret = sysfs_emit(buf,
1115+
"Unused: %zu%%\n"
1116+
"Clean: %zu%%\n"
1117+
"Dirty: %zu%%\n"
1118+
"Metadata: %zu%%\n"
1119+
"Average: %llu\n"
1120+
"Sectors per Q: %zu\n"
1121+
"Quantiles: [",
1122+
unused * 100 / (size_t) ca->sb.nbuckets,
1123+
available * 100 / (size_t) ca->sb.nbuckets,
1124+
dirty * 100 / (size_t) ca->sb.nbuckets,
1125+
meta * 100 / (size_t) ca->sb.nbuckets, sum,
1126+
n * ca->sb.bucket_size / (ARRAY_SIZE(q) + 1));
11271127

11281128
for (i = 0; i < ARRAY_SIZE(q); i++)
1129-
ret += scnprintf(buf + ret, PAGE_SIZE - ret,
1130-
"%u ", q[i]);
1129+
ret += sysfs_emit_at(buf, ret, "%u ", q[i]);
11311130
ret--;
11321131

1133-
ret += scnprintf(buf + ret, PAGE_SIZE - ret, "]\n");
1132+
ret += sysfs_emit_at(buf, ret, "]\n");
11341133

11351134
return ret;
11361135
}

0 commit comments

Comments
 (0)