Skip to content

Commit bc98a42

Browse files
committed
VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)
Firstly by applying the following with coccinelle's spatch: @@ expression SB; @@ -SB->s_flags & MS_RDONLY +sb_rdonly(SB) to effect the conversion to sb_rdonly(sb), then by applying: @@ expression A, SB; @@ ( -(!sb_rdonly(SB)) && A +!sb_rdonly(SB) && A | -A != (sb_rdonly(SB)) +A != sb_rdonly(SB) | -A == (sb_rdonly(SB)) +A == sb_rdonly(SB) | -!(sb_rdonly(SB)) +!sb_rdonly(SB) | -A && (sb_rdonly(SB)) +A && sb_rdonly(SB) | -A || (sb_rdonly(SB)) +A || sb_rdonly(SB) | -(sb_rdonly(SB)) != A +sb_rdonly(SB) != A | -(sb_rdonly(SB)) == A +sb_rdonly(SB) == A | -(sb_rdonly(SB)) && A +sb_rdonly(SB) && A | -(sb_rdonly(SB)) || A +sb_rdonly(SB) || A ) @@ expression A, B, SB; @@ ( -(sb_rdonly(SB)) ? 1 : 0 +sb_rdonly(SB) | -(sb_rdonly(SB)) ? A : B +sb_rdonly(SB) ? A : B ) to remove left over excess bracketage and finally by applying: @@ expression A, SB; @@ ( -(A & MS_RDONLY) != sb_rdonly(SB) +(bool)(A & MS_RDONLY) != sb_rdonly(SB) | -(A & MS_RDONLY) == sb_rdonly(SB) +(bool)(A & MS_RDONLY) == sb_rdonly(SB) ) to make comparisons against the result of sb_rdonly() (which is a bool) work correctly. Signed-off-by: David Howells <dhowells@redhat.com>
1 parent 94e92e7 commit bc98a42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+210
-226
lines changed

drivers/staging/lustre/lustre/llite/llite_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
210210
data->ocd_ibits_known = MDS_INODELOCK_FULL;
211211
data->ocd_version = LUSTRE_VERSION_CODE;
212212

213-
if (sb->s_flags & MS_RDONLY)
213+
if (sb_rdonly(sb))
214214
data->ocd_connect_flags |= OBD_CONNECT_RDONLY;
215215
if (sbi->ll_flags & LL_SBI_USER_XATTR)
216216
data->ocd_connect_flags |= OBD_CONNECT_XATTR;
@@ -2033,7 +2033,7 @@ int ll_remount_fs(struct super_block *sb, int *flags, char *data)
20332033
int err;
20342034
__u32 read_only;
20352035

2036-
if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
2036+
if ((bool)(*flags & MS_RDONLY) != sb_rdonly(sb)) {
20372037
read_only = *flags & MS_RDONLY;
20382038
err = obd_set_info_async(NULL, sbi->ll_md_exp,
20392039
sizeof(KEY_READ_ONLY),

drivers/staging/lustre/lustre/llite/namei.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
562562
}
563563
}
564564

565-
if (it->it_op & IT_OPEN && it->it_flags & FMODE_WRITE &&
566-
dentry->d_sb->s_flags & MS_RDONLY)
565+
if (it->it_op & IT_OPEN && it->it_flags & FMODE_WRITE && sb_rdonly(dentry->d_sb))
567566
return ERR_PTR(-EROFS);
568567

569568
if (it->it_op & IT_CREAT)

fs/affs/amigaffs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...)
450450
vaf.fmt = fmt;
451451
vaf.va = &args;
452452
pr_crit("error (device %s): %s(): %pV\n", sb->s_id, function, &vaf);
453-
if (!(sb->s_flags & MS_RDONLY))
453+
if (!sb_rdonly(sb))
454454
pr_warn("Remounting filesystem read-only\n");
455455
sb->s_flags |= MS_RDONLY;
456456
va_end(args);

fs/affs/bitmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ affs_count_free_blocks(struct super_block *sb)
1919

2020
pr_debug("%s()\n", __func__);
2121

22-
if (sb->s_flags & MS_RDONLY)
22+
if (sb_rdonly(sb))
2323
return 0;
2424

2525
mutex_lock(&AFFS_SB(sb)->s_bmlock);

fs/affs/super.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void affs_mark_sb_dirty(struct super_block *sb)
8080
struct affs_sb_info *sbi = AFFS_SB(sb);
8181
unsigned long delay;
8282

83-
if (sb->s_flags & MS_RDONLY)
83+
if (sb_rdonly(sb))
8484
return;
8585

8686
spin_lock(&sbi->work_lock);
@@ -464,7 +464,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
464464
* not recommended.
465465
*/
466466
if ((chksum == FS_DCFFS || chksum == MUFS_DCFFS || chksum == FS_DCOFS
467-
|| chksum == MUFS_DCOFS) && !(sb->s_flags & MS_RDONLY)) {
467+
|| chksum == MUFS_DCOFS) && !sb_rdonly(sb)) {
468468
pr_notice("Dircache FS - mounting %s read only\n", sb->s_id);
469469
sb->s_flags |= MS_RDONLY;
470470
}
@@ -596,7 +596,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
596596
memcpy(sbi->s_volume, volume, 32);
597597
spin_unlock(&sbi->symlink_lock);
598598

599-
if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
599+
if ((bool)(*flags & MS_RDONLY) == sb_rdonly(sb))
600600
return 0;
601601

602602
if (*flags & MS_RDONLY)

fs/befs/linuxvfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ befs_fill_super(struct super_block *sb, void *data, int silent)
838838

839839
befs_debug(sb, "---> %s", __func__);
840840

841-
if (!(sb->s_flags & MS_RDONLY)) {
841+
if (!sb_rdonly(sb)) {
842842
befs_warning(sb,
843843
"No write support. Marking filesystem read-only");
844844
sb->s_flags |= MS_RDONLY;

fs/btrfs/dev-replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
690690
u64 result;
691691
int ret;
692692

693-
if (fs_info->sb->s_flags & MS_RDONLY)
693+
if (sb_rdonly(fs_info->sb))
694694
return -EROFS;
695695

696696
mutex_lock(&dev_replace->lock_finishing_cancel_unmount);

fs/btrfs/disk-io.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ static int btrfs_replay_log(struct btrfs_fs_info *fs_info,
24782478
return ret;
24792479
}
24802480

2481-
if (fs_info->sb->s_flags & MS_RDONLY) {
2481+
if (sb_rdonly(fs_info->sb)) {
24822482
ret = btrfs_commit_super(fs_info);
24832483
if (ret)
24842484
return ret;
@@ -2874,7 +2874,7 @@ int open_ctree(struct super_block *sb,
28742874

28752875
features = btrfs_super_compat_ro_flags(disk_super) &
28762876
~BTRFS_FEATURE_COMPAT_RO_SUPP;
2877-
if (!(sb->s_flags & MS_RDONLY) && features) {
2877+
if (!sb_rdonly(sb) && features) {
28782878
btrfs_err(fs_info,
28792879
"cannot mount read-write because of unsupported optional features (%llx)",
28802880
features);
@@ -3039,7 +3039,7 @@ int open_ctree(struct super_block *sb,
30393039
btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
30403040
if (fs_info->fs_devices->missing_devices >
30413041
fs_info->num_tolerated_disk_barrier_failures &&
3042-
!(sb->s_flags & MS_RDONLY)) {
3042+
!sb_rdonly(sb)) {
30433043
btrfs_warn(fs_info,
30443044
"missing devices (%llu) exceeds the limit (%d), writeable mount is not allowed",
30453045
fs_info->fs_devices->missing_devices,
@@ -3102,7 +3102,7 @@ int open_ctree(struct super_block *sb,
31023102
if (ret)
31033103
goto fail_qgroup;
31043104

3105-
if (!(sb->s_flags & MS_RDONLY)) {
3105+
if (!sb_rdonly(sb)) {
31063106
ret = btrfs_cleanup_fs_roots(fs_info);
31073107
if (ret)
31083108
goto fail_qgroup;
@@ -3128,7 +3128,7 @@ int open_ctree(struct super_block *sb,
31283128
goto fail_qgroup;
31293129
}
31303130

3131-
if (sb->s_flags & MS_RDONLY)
3131+
if (sb_rdonly(sb))
31323132
return 0;
31333133

31343134
if (btrfs_test_opt(fs_info, CLEAR_CACHE) &&
@@ -3928,7 +3928,7 @@ void close_ctree(struct btrfs_fs_info *fs_info)
39283928

39293929
cancel_work_sync(&fs_info->async_reclaim_work);
39303930

3931-
if (!(fs_info->sb->s_flags & MS_RDONLY)) {
3931+
if (!sb_rdonly(fs_info->sb)) {
39323932
/*
39333933
* If the cleaner thread is stopped and there are
39343934
* block groups queued for removal, the deletion will be

fs/btrfs/extent_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ int repair_eb_io_failure(struct btrfs_fs_info *fs_info,
20612061
unsigned long i, num_pages = num_extent_pages(eb->start, eb->len);
20622062
int ret = 0;
20632063

2064-
if (fs_info->sb->s_flags & MS_RDONLY)
2064+
if (sb_rdonly(fs_info->sb))
20652065
return -EROFS;
20662066

20672067
for (i = 0; i < num_pages; i++) {
@@ -2111,7 +2111,7 @@ int clean_io_failure(struct btrfs_fs_info *fs_info,
21112111
failrec->start);
21122112
goto out;
21132113
}
2114-
if (fs_info->sb->s_flags & MS_RDONLY)
2114+
if (sb_rdonly(fs_info->sb))
21152115
goto out;
21162116

21172117
spin_lock(&io_tree->lock);

fs/btrfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5817,7 +5817,7 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
58175817

58185818
if (!IS_ERR(inode) && root != sub_root) {
58195819
down_read(&fs_info->cleanup_work_sem);
5820-
if (!(inode->i_sb->s_flags & MS_RDONLY))
5820+
if (!sb_rdonly(inode->i_sb))
58215821
ret = btrfs_orphan_cleanup(sub_root);
58225822
up_read(&fs_info->cleanup_work_sem);
58235823
if (ret) {

0 commit comments

Comments
 (0)