Skip to content

Commit b01e1a6

Browse files
Eric Sandeenbrauner
authored andcommitted
freevxfs: Convert freevxfs to the new mount API.
Convert the freevxfs filesystem to the new mount API. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Link: https://lore.kernel.org/r/b0d1a423-4b8e-4bc1-a021-a1078aee915f@redhat.com Tested-by: Krzysztof Błaszkowski <kb@sysmikro.com.pl> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 491681d commit b01e1a6

File tree

1 file changed

+40
-29
lines changed

1 file changed

+40
-29
lines changed

fs/freevxfs/vxfs_super.c

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <linux/slab.h>
1818
#include <linux/stat.h>
1919
#include <linux/vfs.h>
20-
#include <linux/mount.h>
20+
#include <linux/fs_context.h>
2121

2222
#include "vxfs.h"
2323
#include "vxfs_extern.h"
@@ -91,10 +91,10 @@ vxfs_statfs(struct dentry *dentry, struct kstatfs *bufp)
9191
return 0;
9292
}
9393

94-
static int vxfs_remount(struct super_block *sb, int *flags, char *data)
94+
static int vxfs_reconfigure(struct fs_context *fc)
9595
{
96-
sync_filesystem(sb);
97-
*flags |= SB_RDONLY;
96+
sync_filesystem(fc->root->d_sb);
97+
fc->sb_flags |= SB_RDONLY;
9898
return 0;
9999
}
100100

@@ -120,24 +120,24 @@ static const struct super_operations vxfs_super_ops = {
120120
.evict_inode = vxfs_evict_inode,
121121
.put_super = vxfs_put_super,
122122
.statfs = vxfs_statfs,
123-
.remount_fs = vxfs_remount,
124123
};
125124

126-
static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
125+
static int vxfs_try_sb_magic(struct super_block *sbp, struct fs_context *fc,
127126
unsigned blk, __fs32 magic)
128127
{
129128
struct buffer_head *bp;
130129
struct vxfs_sb *rsbp;
131130
struct vxfs_sb_info *infp = VXFS_SBI(sbp);
131+
int silent = fc->sb_flags & SB_SILENT;
132132
int rc = -ENOMEM;
133133

134134
bp = sb_bread(sbp, blk);
135135
do {
136136
if (!bp || !buffer_mapped(bp)) {
137137
if (!silent) {
138-
printk(KERN_WARNING
139-
"vxfs: unable to read disk superblock at %u\n",
140-
blk);
138+
warnf(fc,
139+
"vxfs: unable to read disk superblock at %u",
140+
blk);
141141
}
142142
break;
143143
}
@@ -146,9 +146,9 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
146146
rsbp = (struct vxfs_sb *)bp->b_data;
147147
if (rsbp->vs_magic != magic) {
148148
if (!silent)
149-
printk(KERN_NOTICE
150-
"vxfs: WRONG superblock magic %08x at %u\n",
151-
rsbp->vs_magic, blk);
149+
infof(fc,
150+
"vxfs: WRONG superblock magic %08x at %u",
151+
rsbp->vs_magic, blk);
152152
break;
153153
}
154154

@@ -169,8 +169,7 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
169169
/**
170170
* vxfs_fill_super - read superblock into memory and initialize filesystem
171171
* @sbp: VFS superblock (to fill)
172-
* @dp: fs private mount data
173-
* @silent: do not complain loudly when sth is wrong
172+
* @fc: filesytem context
174173
*
175174
* Description:
176175
* We are called on the first mount of a filesystem to read the
@@ -182,26 +181,27 @@ static int vxfs_try_sb_magic(struct super_block *sbp, int silent,
182181
* Locking:
183182
* We are under @sbp->s_lock.
184183
*/
185-
static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
184+
static int vxfs_fill_super(struct super_block *sbp, struct fs_context *fc)
186185
{
187186
struct vxfs_sb_info *infp;
188187
struct vxfs_sb *rsbp;
189188
u_long bsize;
190189
struct inode *root;
191190
int ret = -EINVAL;
191+
int silent = fc->sb_flags & SB_SILENT;
192192
u32 j;
193193

194194
sbp->s_flags |= SB_RDONLY;
195195

196196
infp = kzalloc(sizeof(*infp), GFP_KERNEL);
197197
if (!infp) {
198-
printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n");
198+
warnf(fc, "vxfs: unable to allocate incore superblock");
199199
return -ENOMEM;
200200
}
201201

202202
bsize = sb_min_blocksize(sbp, BLOCK_SIZE);
203203
if (!bsize) {
204-
printk(KERN_WARNING "vxfs: unable to set blocksize\n");
204+
warnf(fc, "vxfs: unable to set blocksize");
205205
goto out;
206206
}
207207

@@ -210,24 +210,24 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
210210
sbp->s_time_min = 0;
211211
sbp->s_time_max = U32_MAX;
212212

213-
if (!vxfs_try_sb_magic(sbp, silent, 1,
213+
if (!vxfs_try_sb_magic(sbp, fc, 1,
214214
(__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) {
215215
/* Unixware, x86 */
216216
infp->byte_order = VXFS_BO_LE;
217-
} else if (!vxfs_try_sb_magic(sbp, silent, 8,
217+
} else if (!vxfs_try_sb_magic(sbp, fc, 8,
218218
(__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) {
219219
/* HP-UX, parisc */
220220
infp->byte_order = VXFS_BO_BE;
221221
} else {
222222
if (!silent)
223-
printk(KERN_NOTICE "vxfs: can't find superblock.\n");
223+
infof(fc, "vxfs: can't find superblock.");
224224
goto out;
225225
}
226226

227227
rsbp = infp->vsi_raw;
228228
j = fs32_to_cpu(infp, rsbp->vs_version);
229229
if ((j < 2 || j > 4) && !silent) {
230-
printk(KERN_NOTICE "vxfs: unsupported VxFS version (%d)\n", j);
230+
infof(fc, "vxfs: unsupported VxFS version (%d)", j);
231231
goto out;
232232
}
233233

@@ -244,17 +244,17 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
244244

245245
j = fs32_to_cpu(infp, rsbp->vs_bsize);
246246
if (!sb_set_blocksize(sbp, j)) {
247-
printk(KERN_WARNING "vxfs: unable to set final block size\n");
247+
warnf(fc, "vxfs: unable to set final block size");
248248
goto out;
249249
}
250250

251251
if (vxfs_read_olt(sbp, bsize)) {
252-
printk(KERN_WARNING "vxfs: unable to read olt\n");
252+
warnf(fc, "vxfs: unable to read olt");
253253
goto out;
254254
}
255255

256256
if (vxfs_read_fshead(sbp)) {
257-
printk(KERN_WARNING "vxfs: unable to read fshead\n");
257+
warnf(fc, "vxfs: unable to read fshead");
258258
goto out;
259259
}
260260

@@ -265,7 +265,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
265265
}
266266
sbp->s_root = d_make_root(root);
267267
if (!sbp->s_root) {
268-
printk(KERN_WARNING "vxfs: unable to get root dentry.\n");
268+
warnf(fc, "vxfs: unable to get root dentry.");
269269
goto out_free_ilist;
270270
}
271271

@@ -284,18 +284,29 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent)
284284
/*
285285
* The usual module blurb.
286286
*/
287-
static struct dentry *vxfs_mount(struct file_system_type *fs_type,
288-
int flags, const char *dev_name, void *data)
287+
static int vxfs_get_tree(struct fs_context *fc)
289288
{
290-
return mount_bdev(fs_type, flags, dev_name, data, vxfs_fill_super);
289+
return get_tree_bdev(fc, vxfs_fill_super);
290+
}
291+
292+
static const struct fs_context_operations vxfs_context_ops = {
293+
.get_tree = vxfs_get_tree,
294+
.reconfigure = vxfs_reconfigure,
295+
};
296+
297+
static int vxfs_init_fs_context(struct fs_context *fc)
298+
{
299+
fc->ops = &vxfs_context_ops;
300+
301+
return 0;
291302
}
292303

293304
static struct file_system_type vxfs_fs_type = {
294305
.owner = THIS_MODULE,
295306
.name = "vxfs",
296-
.mount = vxfs_mount,
297307
.kill_sb = kill_block_super,
298308
.fs_flags = FS_REQUIRES_DEV,
309+
.init_fs_context = vxfs_init_fs_context,
299310
};
300311
MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */
301312
MODULE_ALIAS("vxfs");

0 commit comments

Comments
 (0)