Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Sandeen and committed by
Christian Brauner
b01e1a63 491681d4

+40 -29
+40 -29
fs/freevxfs/vxfs_super.c
··· 17 17 #include <linux/slab.h> 18 18 #include <linux/stat.h> 19 19 #include <linux/vfs.h> 20 - #include <linux/mount.h> 20 + #include <linux/fs_context.h> 21 21 22 22 #include "vxfs.h" 23 23 #include "vxfs_extern.h" ··· 91 91 return 0; 92 92 } 93 93 94 - static int vxfs_remount(struct super_block *sb, int *flags, char *data) 94 + static int vxfs_reconfigure(struct fs_context *fc) 95 95 { 96 - sync_filesystem(sb); 97 - *flags |= SB_RDONLY; 96 + sync_filesystem(fc->root->d_sb); 97 + fc->sb_flags |= SB_RDONLY; 98 98 return 0; 99 99 } 100 100 ··· 120 120 .evict_inode = vxfs_evict_inode, 121 121 .put_super = vxfs_put_super, 122 122 .statfs = vxfs_statfs, 123 - .remount_fs = vxfs_remount, 124 123 }; 125 124 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, 127 126 unsigned blk, __fs32 magic) 128 127 { 129 128 struct buffer_head *bp; 130 129 struct vxfs_sb *rsbp; 131 130 struct vxfs_sb_info *infp = VXFS_SBI(sbp); 131 + int silent = fc->sb_flags & SB_SILENT; 132 132 int rc = -ENOMEM; 133 133 134 134 bp = sb_bread(sbp, blk); 135 135 do { 136 136 if (!bp || !buffer_mapped(bp)) { 137 137 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); 141 141 } 142 142 break; 143 143 } ··· 146 146 rsbp = (struct vxfs_sb *)bp->b_data; 147 147 if (rsbp->vs_magic != magic) { 148 148 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); 152 152 break; 153 153 } 154 154 ··· 169 169 /** 170 170 * vxfs_fill_super - read superblock into memory and initialize filesystem 171 171 * @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 174 173 * 175 174 * Description: 176 175 * We are called on the first mount of a filesystem to read the ··· 181 182 * Locking: 182 183 * We are under @sbp->s_lock. 183 184 */ 184 - static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) 185 + static int vxfs_fill_super(struct super_block *sbp, struct fs_context *fc) 185 186 { 186 187 struct vxfs_sb_info *infp; 187 188 struct vxfs_sb *rsbp; 188 189 u_long bsize; 189 190 struct inode *root; 190 191 int ret = -EINVAL; 192 + int silent = fc->sb_flags & SB_SILENT; 191 193 u32 j; 192 194 193 195 sbp->s_flags |= SB_RDONLY; 194 196 195 197 infp = kzalloc(sizeof(*infp), GFP_KERNEL); 196 198 if (!infp) { 197 - printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n"); 199 + warnf(fc, "vxfs: unable to allocate incore superblock"); 198 200 return -ENOMEM; 199 201 } 200 202 201 203 bsize = sb_min_blocksize(sbp, BLOCK_SIZE); 202 204 if (!bsize) { 203 - printk(KERN_WARNING "vxfs: unable to set blocksize\n"); 205 + warnf(fc, "vxfs: unable to set blocksize"); 204 206 goto out; 205 207 } 206 208 ··· 210 210 sbp->s_time_min = 0; 211 211 sbp->s_time_max = U32_MAX; 212 212 213 - if (!vxfs_try_sb_magic(sbp, silent, 1, 213 + if (!vxfs_try_sb_magic(sbp, fc, 1, 214 214 (__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) { 215 215 /* Unixware, x86 */ 216 216 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, 218 218 (__force __fs32)cpu_to_be32(VXFS_SUPER_MAGIC))) { 219 219 /* HP-UX, parisc */ 220 220 infp->byte_order = VXFS_BO_BE; 221 221 } else { 222 222 if (!silent) 223 - printk(KERN_NOTICE "vxfs: can't find superblock.\n"); 223 + infof(fc, "vxfs: can't find superblock."); 224 224 goto out; 225 225 } 226 226 227 227 rsbp = infp->vsi_raw; 228 228 j = fs32_to_cpu(infp, rsbp->vs_version); 229 229 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); 231 231 goto out; 232 232 } 233 233 ··· 244 244 245 245 j = fs32_to_cpu(infp, rsbp->vs_bsize); 246 246 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"); 248 248 goto out; 249 249 } 250 250 251 251 if (vxfs_read_olt(sbp, bsize)) { 252 - printk(KERN_WARNING "vxfs: unable to read olt\n"); 252 + warnf(fc, "vxfs: unable to read olt"); 253 253 goto out; 254 254 } 255 255 256 256 if (vxfs_read_fshead(sbp)) { 257 - printk(KERN_WARNING "vxfs: unable to read fshead\n"); 257 + warnf(fc, "vxfs: unable to read fshead"); 258 258 goto out; 259 259 } 260 260 ··· 265 265 } 266 266 sbp->s_root = d_make_root(root); 267 267 if (!sbp->s_root) { 268 - printk(KERN_WARNING "vxfs: unable to get root dentry.\n"); 268 + warnf(fc, "vxfs: unable to get root dentry."); 269 269 goto out_free_ilist; 270 270 } 271 271 ··· 284 284 /* 285 285 * The usual module blurb. 286 286 */ 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) 289 288 { 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; 291 302 } 292 303 293 304 static struct file_system_type vxfs_fs_type = { 294 305 .owner = THIS_MODULE, 295 306 .name = "vxfs", 296 - .mount = vxfs_mount, 297 307 .kill_sb = kill_block_super, 298 308 .fs_flags = FS_REQUIRES_DEV, 309 + .init_fs_context = vxfs_init_fs_context, 299 310 }; 300 311 MODULE_ALIAS_FS("vxfs"); /* makes mount -t vxfs autoload the module */ 301 312 MODULE_ALIAS("vxfs");