Skip to content

Commit 3d23985

Browse files
author
Al Viro
committed
switch fat to ->s_d_op, close exportfs races there
don't bother with lock_super() in fat_fill_super() callers, while we are at it - there won't be any concurrency anyway. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 6cc9c1d commit 3d23985

4 files changed

Lines changed: 25 additions & 45 deletions

File tree

‎fs/fat/fat.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ extern struct inode *fat_build_inode(struct super_block *sb,
319319
struct msdos_dir_entry *de, loff_t i_pos);
320320
extern int fat_sync_inode(struct inode *inode);
321321
extern int fat_fill_super(struct super_block *sb, void *data, int silent,
322-
const struct inode_operations *fs_dir_inode_ops, int isvfat);
322+
const struct inode_operations *fs_dir_inode_ops,
323+
int isvfat, void (*setup)(struct super_block *));
323324

324325
extern int fat_flush_inodes(struct super_block *sb, struct inode *i1,
325326
struct inode *i2);

‎fs/fat/inode.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ static struct dentry *fat_fh_to_dentry(struct super_block *sb,
703703
struct fid *fid, int fh_len, int fh_type)
704704
{
705705
struct inode *inode = NULL;
706-
struct dentry *result;
707706
u32 *fh = fid->raw;
708707

709708
if (fh_len < 5 || fh_type != 3)
@@ -748,10 +747,7 @@ static struct dentry *fat_fh_to_dentry(struct super_block *sb,
748747
* the fat_iget lookup again. If that fails, then we are totally out
749748
* of luck. But all that is for another day
750749
*/
751-
result = d_obtain_alias(inode);
752-
if (!IS_ERR(result))
753-
d_set_d_op(result, sb->s_root->d_op);
754-
return result;
750+
return d_obtain_alias(inode);
755751
}
756752

757753
static int
@@ -799,8 +795,6 @@ static struct dentry *fat_get_parent(struct dentry *child)
799795
brelse(bh);
800796

801797
parent = d_obtain_alias(inode);
802-
if (!IS_ERR(parent))
803-
d_set_d_op(parent, sb->s_root->d_op);
804798
out:
805799
unlock_super(sb);
806800

@@ -1244,7 +1238,8 @@ static int fat_read_root(struct inode *inode)
12441238
* Read the super block of an MS-DOS FS.
12451239
*/
12461240
int fat_fill_super(struct super_block *sb, void *data, int silent,
1247-
const struct inode_operations *fs_dir_inode_ops, int isvfat)
1241+
const struct inode_operations *fs_dir_inode_ops, int isvfat,
1242+
void (*setup)(struct super_block *))
12481243
{
12491244
struct inode *root_inode = NULL, *fat_inode = NULL;
12501245
struct buffer_head *bh;
@@ -1280,6 +1275,8 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
12801275
if (error)
12811276
goto out_fail;
12821277

1278+
setup(sb); /* flavour-specific stuff that needs options */
1279+
12831280
error = -EIO;
12841281
sb_min_blocksize(sb, 512);
12851282
bh = sb_bread(sb, 0);

‎fs/fat/namei_msdos.c‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry,
227227
}
228228
out:
229229
unlock_super(sb);
230-
d_set_d_op(dentry, &msdos_dentry_operations);
231-
dentry = d_splice_alias(inode, dentry);
232-
if (dentry)
233-
d_set_d_op(dentry, &msdos_dentry_operations);
234-
return dentry;
230+
return d_splice_alias(inode, dentry);
235231

236232
error:
237233
unlock_super(sb);
@@ -661,21 +657,16 @@ static const struct inode_operations msdos_dir_inode_operations = {
661657
.getattr = fat_getattr,
662658
};
663659

664-
static int msdos_fill_super(struct super_block *sb, void *data, int silent)
660+
static void setup(struct super_block *sb)
665661
{
666-
int res;
667-
668-
lock_super(sb);
669-
res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0);
670-
if (res) {
671-
unlock_super(sb);
672-
return res;
673-
}
674-
662+
sb->s_d_op = &msdos_dentry_operations;
675663
sb->s_flags |= MS_NOATIME;
676-
d_set_d_op(sb->s_root, &msdos_dentry_operations);
677-
unlock_super(sb);
678-
return 0;
664+
}
665+
666+
static int msdos_fill_super(struct super_block *sb, void *data, int silent)
667+
{
668+
return fat_fill_super(sb, data, silent, &msdos_dir_inode_operations,
669+
0, setup);
679670
}
680671

681672
static struct dentry *msdos_mount(struct file_system_type *fs_type,

‎fs/fat/namei_vfat.c‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,10 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
772772

773773
out:
774774
unlock_super(sb);
775-
d_set_d_op(dentry, sb->s_root->d_op);
776775
dentry->d_time = dentry->d_parent->d_inode->i_version;
777776
dentry = d_splice_alias(inode, dentry);
778-
if (dentry) {
779-
d_set_d_op(dentry, sb->s_root->d_op);
777+
if (dentry)
780778
dentry->d_time = dentry->d_parent->d_inode->i_version;
781-
}
782779
return dentry;
783780

784781
error:
@@ -1066,24 +1063,18 @@ static const struct inode_operations vfat_dir_inode_operations = {
10661063
.getattr = fat_getattr,
10671064
};
10681065

1069-
static int vfat_fill_super(struct super_block *sb, void *data, int silent)
1066+
static void setup(struct super_block *sb)
10701067
{
1071-
int res;
1072-
1073-
lock_super(sb);
1074-
res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1);
1075-
if (res) {
1076-
unlock_super(sb);
1077-
return res;
1078-
}
1079-
10801068
if (MSDOS_SB(sb)->options.name_check != 's')
1081-
d_set_d_op(sb->s_root, &vfat_ci_dentry_ops);
1069+
sb->s_d_op = &vfat_ci_dentry_ops;
10821070
else
1083-
d_set_d_op(sb->s_root, &vfat_dentry_ops);
1071+
sb->s_d_op = &vfat_dentry_ops;
1072+
}
10841073

1085-
unlock_super(sb);
1086-
return 0;
1074+
static int vfat_fill_super(struct super_block *sb, void *data, int silent)
1075+
{
1076+
return fat_fill_super(sb, data, silent, &vfat_dir_inode_operations,
1077+
1, setup);
10871078
}
10881079

10891080
static struct dentry *vfat_mount(struct file_system_type *fs_type,

0 commit comments

Comments
 (0)