Revert "nilfs2: replace snprintf in show functions with sysfs_emit"

This reverts commit bd580a7fd9.
This commit is contained in:
Ksawlii 2024-11-24 00:23:37 +01:00
parent acfc7f60d9
commit 2a04905087

View file

@ -108,7 +108,7 @@ static ssize_t
nilfs_snapshot_inodes_count_show(struct nilfs_snapshot_attr *attr,
struct nilfs_root *root, char *buf)
{
return sysfs_emit(buf, "%llu\n",
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)atomic64_read(&root->inodes_count));
}
@ -116,7 +116,7 @@ static ssize_t
nilfs_snapshot_blocks_count_show(struct nilfs_snapshot_attr *attr,
struct nilfs_root *root, char *buf)
{
return sysfs_emit(buf, "%llu\n",
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)atomic64_read(&root->blocks_count));
}
@ -129,7 +129,7 @@ static ssize_t
nilfs_snapshot_README_show(struct nilfs_snapshot_attr *attr,
struct nilfs_root *root, char *buf)
{
return sysfs_emit(buf, snapshot_readme_str);
return snprintf(buf, PAGE_SIZE, snapshot_readme_str);
}
NILFS_SNAPSHOT_RO_ATTR(inodes_count);
@ -230,7 +230,7 @@ static ssize_t
nilfs_mounted_snapshots_README_show(struct nilfs_mounted_snapshots_attr *attr,
struct the_nilfs *nilfs, char *buf)
{
return sysfs_emit(buf, mounted_snapshots_readme_str);
return snprintf(buf, PAGE_SIZE, mounted_snapshots_readme_str);
}
NILFS_MOUNTED_SNAPSHOTS_RO_ATTR(README);
@ -268,7 +268,7 @@ nilfs_checkpoints_checkpoints_number_show(struct nilfs_checkpoints_attr *attr,
ncheckpoints = cpstat.cs_ncps;
return sysfs_emit(buf, "%llu\n", ncheckpoints);
return snprintf(buf, PAGE_SIZE, "%llu\n", ncheckpoints);
}
static ssize_t
@ -291,7 +291,7 @@ nilfs_checkpoints_snapshots_number_show(struct nilfs_checkpoints_attr *attr,
nsnapshots = cpstat.cs_nsss;
return sysfs_emit(buf, "%llu\n", nsnapshots);
return snprintf(buf, PAGE_SIZE, "%llu\n", nsnapshots);
}
static ssize_t
@ -305,7 +305,7 @@ nilfs_checkpoints_last_seg_checkpoint_show(struct nilfs_checkpoints_attr *attr,
last_cno = nilfs->ns_last_cno;
spin_unlock(&nilfs->ns_last_segment_lock);
return sysfs_emit(buf, "%llu\n", last_cno);
return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno);
}
static ssize_t
@ -319,7 +319,7 @@ nilfs_checkpoints_next_checkpoint_show(struct nilfs_checkpoints_attr *attr,
cno = nilfs->ns_cno;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", cno);
return snprintf(buf, PAGE_SIZE, "%llu\n", cno);
}
static const char checkpoints_readme_str[] =
@ -335,7 +335,7 @@ static ssize_t
nilfs_checkpoints_README_show(struct nilfs_checkpoints_attr *attr,
struct the_nilfs *nilfs, char *buf)
{
return sysfs_emit(buf, checkpoints_readme_str);
return snprintf(buf, PAGE_SIZE, checkpoints_readme_str);
}
NILFS_CHECKPOINTS_RO_ATTR(checkpoints_number);
@ -366,7 +366,7 @@ nilfs_segments_segments_number_show(struct nilfs_segments_attr *attr,
struct the_nilfs *nilfs,
char *buf)
{
return sysfs_emit(buf, "%lu\n", nilfs->ns_nsegments);
return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_nsegments);
}
static ssize_t
@ -374,7 +374,7 @@ nilfs_segments_blocks_per_segment_show(struct nilfs_segments_attr *attr,
struct the_nilfs *nilfs,
char *buf)
{
return sysfs_emit(buf, "%lu\n", nilfs->ns_blocks_per_segment);
return snprintf(buf, PAGE_SIZE, "%lu\n", nilfs->ns_blocks_per_segment);
}
static ssize_t
@ -388,7 +388,7 @@ nilfs_segments_clean_segments_show(struct nilfs_segments_attr *attr,
ncleansegs = nilfs_sufile_get_ncleansegs(nilfs->ns_sufile);
up_read(&NILFS_MDT(nilfs->ns_dat)->mi_sem);
return sysfs_emit(buf, "%lu\n", ncleansegs);
return snprintf(buf, PAGE_SIZE, "%lu\n", ncleansegs);
}
static ssize_t
@ -408,7 +408,7 @@ nilfs_segments_dirty_segments_show(struct nilfs_segments_attr *attr,
return err;
}
return sysfs_emit(buf, "%llu\n", sustat.ss_ndirtysegs);
return snprintf(buf, PAGE_SIZE, "%llu\n", sustat.ss_ndirtysegs);
}
static const char segments_readme_str[] =
@ -424,7 +424,7 @@ nilfs_segments_README_show(struct nilfs_segments_attr *attr,
struct the_nilfs *nilfs,
char *buf)
{
return sysfs_emit(buf, segments_readme_str);
return snprintf(buf, PAGE_SIZE, segments_readme_str);
}
NILFS_SEGMENTS_RO_ATTR(segments_number);
@ -461,7 +461,7 @@ nilfs_segctor_last_pseg_block_show(struct nilfs_segctor_attr *attr,
last_pseg = nilfs->ns_last_pseg;
spin_unlock(&nilfs->ns_last_segment_lock);
return sysfs_emit(buf, "%llu\n",
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)last_pseg);
}
@ -476,7 +476,7 @@ nilfs_segctor_last_seg_sequence_show(struct nilfs_segctor_attr *attr,
last_seq = nilfs->ns_last_seq;
spin_unlock(&nilfs->ns_last_segment_lock);
return sysfs_emit(buf, "%llu\n", last_seq);
return snprintf(buf, PAGE_SIZE, "%llu\n", last_seq);
}
static ssize_t
@ -490,7 +490,7 @@ nilfs_segctor_last_seg_checkpoint_show(struct nilfs_segctor_attr *attr,
last_cno = nilfs->ns_last_cno;
spin_unlock(&nilfs->ns_last_segment_lock);
return sysfs_emit(buf, "%llu\n", last_cno);
return snprintf(buf, PAGE_SIZE, "%llu\n", last_cno);
}
static ssize_t
@ -504,7 +504,7 @@ nilfs_segctor_current_seg_sequence_show(struct nilfs_segctor_attr *attr,
seg_seq = nilfs->ns_seg_seq;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", seg_seq);
return snprintf(buf, PAGE_SIZE, "%llu\n", seg_seq);
}
static ssize_t
@ -518,7 +518,7 @@ nilfs_segctor_current_last_full_seg_show(struct nilfs_segctor_attr *attr,
segnum = nilfs->ns_segnum;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", segnum);
return snprintf(buf, PAGE_SIZE, "%llu\n", segnum);
}
static ssize_t
@ -532,7 +532,7 @@ nilfs_segctor_next_full_seg_show(struct nilfs_segctor_attr *attr,
nextnum = nilfs->ns_nextnum;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", nextnum);
return snprintf(buf, PAGE_SIZE, "%llu\n", nextnum);
}
static ssize_t
@ -546,7 +546,7 @@ nilfs_segctor_next_pseg_offset_show(struct nilfs_segctor_attr *attr,
pseg_offset = nilfs->ns_pseg_offset;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%lu\n", pseg_offset);
return snprintf(buf, PAGE_SIZE, "%lu\n", pseg_offset);
}
static ssize_t
@ -560,7 +560,7 @@ nilfs_segctor_next_checkpoint_show(struct nilfs_segctor_attr *attr,
cno = nilfs->ns_cno;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", cno);
return snprintf(buf, PAGE_SIZE, "%llu\n", cno);
}
static ssize_t
@ -588,7 +588,7 @@ nilfs_segctor_last_seg_write_time_secs_show(struct nilfs_segctor_attr *attr,
ctime = nilfs->ns_ctime;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", ctime);
return snprintf(buf, PAGE_SIZE, "%llu\n", ctime);
}
static ssize_t
@ -616,7 +616,7 @@ nilfs_segctor_last_nongc_write_time_secs_show(struct nilfs_segctor_attr *attr,
nongc_ctime = nilfs->ns_nongc_ctime;
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%llu\n", nongc_ctime);
return snprintf(buf, PAGE_SIZE, "%llu\n", nongc_ctime);
}
static ssize_t
@ -630,7 +630,7 @@ nilfs_segctor_dirty_data_blocks_count_show(struct nilfs_segctor_attr *attr,
ndirtyblks = atomic_read(&nilfs->ns_ndirtyblks);
up_read(&nilfs->ns_segctor_sem);
return sysfs_emit(buf, "%u\n", ndirtyblks);
return snprintf(buf, PAGE_SIZE, "%u\n", ndirtyblks);
}
static const char segctor_readme_str[] =
@ -667,7 +667,7 @@ static ssize_t
nilfs_segctor_README_show(struct nilfs_segctor_attr *attr,
struct the_nilfs *nilfs, char *buf)
{
return sysfs_emit(buf, segctor_readme_str);
return snprintf(buf, PAGE_SIZE, segctor_readme_str);
}
NILFS_SEGCTOR_RO_ATTR(last_pseg_block);
@ -736,7 +736,7 @@ nilfs_superblock_sb_write_time_secs_show(struct nilfs_superblock_attr *attr,
sbwtime = nilfs->ns_sbwtime;
up_read(&nilfs->ns_sem);
return sysfs_emit(buf, "%llu\n", sbwtime);
return snprintf(buf, PAGE_SIZE, "%llu\n", sbwtime);
}
static ssize_t
@ -750,7 +750,7 @@ nilfs_superblock_sb_write_count_show(struct nilfs_superblock_attr *attr,
sbwcount = nilfs->ns_sbwcount;
up_read(&nilfs->ns_sem);
return sysfs_emit(buf, "%u\n", sbwcount);
return snprintf(buf, PAGE_SIZE, "%u\n", sbwcount);
}
static ssize_t
@ -764,7 +764,7 @@ nilfs_superblock_sb_update_frequency_show(struct nilfs_superblock_attr *attr,
sb_update_freq = nilfs->ns_sb_update_freq;
up_read(&nilfs->ns_sem);
return sysfs_emit(buf, "%u\n", sb_update_freq);
return snprintf(buf, PAGE_SIZE, "%u\n", sb_update_freq);
}
static ssize_t
@ -812,7 +812,7 @@ static ssize_t
nilfs_superblock_README_show(struct nilfs_superblock_attr *attr,
struct the_nilfs *nilfs, char *buf)
{
return sysfs_emit(buf, sb_readme_str);
return snprintf(buf, PAGE_SIZE, sb_readme_str);
}
NILFS_SUPERBLOCK_RO_ATTR(sb_write_time);
@ -847,7 +847,7 @@ ssize_t nilfs_dev_revision_show(struct nilfs_dev_attr *attr,
u32 major = le32_to_cpu(sbp[0]->s_rev_level);
u16 minor = le16_to_cpu(sbp[0]->s_minor_rev_level);
return sysfs_emit(buf, "%d.%d\n", major, minor);
return snprintf(buf, PAGE_SIZE, "%d.%d\n", major, minor);
}
static
@ -855,7 +855,7 @@ ssize_t nilfs_dev_blocksize_show(struct nilfs_dev_attr *attr,
struct the_nilfs *nilfs,
char *buf)
{
return sysfs_emit(buf, "%u\n", nilfs->ns_blocksize);
return snprintf(buf, PAGE_SIZE, "%u\n", nilfs->ns_blocksize);
}
static
@ -866,7 +866,7 @@ ssize_t nilfs_dev_device_size_show(struct nilfs_dev_attr *attr,
struct nilfs_super_block **sbp = nilfs->ns_sbp;
u64 dev_size = le64_to_cpu(sbp[0]->s_dev_size);
return sysfs_emit(buf, "%llu\n", dev_size);
return snprintf(buf, PAGE_SIZE, "%llu\n", dev_size);
}
static
@ -877,7 +877,7 @@ ssize_t nilfs_dev_free_blocks_show(struct nilfs_dev_attr *attr,
sector_t free_blocks = 0;
nilfs_count_free_blocks(nilfs, &free_blocks);
return sysfs_emit(buf, "%llu\n",
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)free_blocks);
}
@ -888,7 +888,7 @@ ssize_t nilfs_dev_uuid_show(struct nilfs_dev_attr *attr,
{
struct nilfs_super_block **sbp = nilfs->ns_sbp;
return sysfs_emit(buf, "%pUb\n", sbp[0]->s_uuid);
return snprintf(buf, PAGE_SIZE, "%pUb\n", sbp[0]->s_uuid);
}
static
@ -916,7 +916,7 @@ static ssize_t nilfs_dev_README_show(struct nilfs_dev_attr *attr,
struct the_nilfs *nilfs,
char *buf)
{
return sysfs_emit(buf, dev_readme_str);
return snprintf(buf, PAGE_SIZE, dev_readme_str);
}
NILFS_DEV_RO_ATTR(revision);
@ -1060,7 +1060,7 @@ void nilfs_sysfs_delete_device_group(struct the_nilfs *nilfs)
static ssize_t nilfs_feature_revision_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
return sysfs_emit(buf, "%d.%d\n",
return snprintf(buf, PAGE_SIZE, "%d.%d\n",
NILFS_CURRENT_REV, NILFS_MINOR_REV);
}
@ -1073,7 +1073,7 @@ static ssize_t nilfs_feature_README_show(struct kobject *kobj,
struct attribute *attr,
char *buf)
{
return sysfs_emit(buf, features_readme_str);
return snprintf(buf, PAGE_SIZE, features_readme_str);
}
NILFS_FEATURE_RO_ATTR(revision);