Deleted Added
full compact
ffs_vfsops.c (132805) ffs_vfsops.c (132902)
1/*
2 * Copyright (c) 1989, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95
30 */
31
32#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1989, 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)ffs_vfsops.c 8.31 (Berkeley) 5/20/95
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_vfsops.c 132805 2004-07-28 20:21:04Z phk $");
33__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_vfsops.c 132902 2004-07-30 22:08:52Z phk $");
34
35#include "opt_mac.h"
36#include "opt_quota.h"
37#include "opt_ufs.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/namei.h>

--- 21 unchanged lines hidden (view full) ---

63
64#include <vm/vm.h>
65#include <vm/uma.h>
66#include <vm/vm_page.h>
67
68uma_zone_t uma_inode, uma_ufs1, uma_ufs2;
69
70static int ffs_sbupdate(struct ufsmount *, int);
34
35#include "opt_mac.h"
36#include "opt_quota.h"
37#include "opt_ufs.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/namei.h>

--- 21 unchanged lines hidden (view full) ---

63
64#include <vm/vm.h>
65#include <vm/uma.h>
66#include <vm/vm_page.h>
67
68uma_zone_t uma_inode, uma_ufs1, uma_ufs2;
69
70static int ffs_sbupdate(struct ufsmount *, int);
71 int ffs_reload(struct mount *,struct ucred *,struct thread *);
71static int ffs_reload(struct mount *, struct thread *);
72static int ffs_mountfs(struct vnode *, struct mount *, struct thread *);
73static void ffs_oldfscompat_read(struct fs *, struct ufsmount *,
74 ufs2_daddr_t);
75static void ffs_oldfscompat_write(struct fs *, struct ufsmount *);
76static void ffs_ifree(struct ufsmount *ump, struct inode *ip);
77static vfs_init_t ffs_init;
78static vfs_uninit_t ffs_uninit;
79static vfs_extattrctl_t ffs_extattrctl;
72static int ffs_mountfs(struct vnode *, struct mount *, struct thread *);
73static void ffs_oldfscompat_read(struct fs *, struct ufsmount *,
74 ufs2_daddr_t);
75static void ffs_oldfscompat_write(struct fs *, struct ufsmount *);
76static void ffs_ifree(struct ufsmount *ump, struct inode *ip);
77static vfs_init_t ffs_init;
78static vfs_uninit_t ffs_uninit;
79static vfs_extattrctl_t ffs_extattrctl;
80static vfs_omount_t ffs_omount;
80
81static struct vfsops ufs_vfsops = {
82 .vfs_extattrctl = ffs_extattrctl,
83 .vfs_fhtovp = ffs_fhtovp,
84 .vfs_init = ffs_init,
81
82static struct vfsops ufs_vfsops = {
83 .vfs_extattrctl = ffs_extattrctl,
84 .vfs_fhtovp = ffs_fhtovp,
85 .vfs_init = ffs_init,
85 .vfs_mount = ffs_mount,
86 .vfs_omount = ffs_omount,
86 .vfs_quotactl = ufs_quotactl,
87 .vfs_root = ufs_root,
88 .vfs_start = ufs_start,
89 .vfs_statfs = ffs_statfs,
90 .vfs_sync = ffs_sync,
91 .vfs_uninit = ffs_uninit,
92 .vfs_unmount = ffs_unmount,
93 .vfs_vget = ffs_vget,
94 .vfs_vptofh = ffs_vptofh,
95};
96
97VFS_SET(ufs_vfsops, ufs, 0);
98
99/*
87 .vfs_quotactl = ufs_quotactl,
88 .vfs_root = ufs_root,
89 .vfs_start = ufs_start,
90 .vfs_statfs = ffs_statfs,
91 .vfs_sync = ffs_sync,
92 .vfs_uninit = ffs_uninit,
93 .vfs_unmount = ffs_unmount,
94 .vfs_vget = ffs_vget,
95 .vfs_vptofh = ffs_vptofh,
96};
97
98VFS_SET(ufs_vfsops, ufs, 0);
99
100/*
100 * ffs_mount
101 * ffs_omount
101 *
102 * Called when mounting local physical media
103 *
104 * PARAMETERS:
105 * mountroot
106 * mp mount point structure
107 * path NULL (flag for root mount!!!)
108 * data <unused>

--- 19 unchanged lines hidden (view full) ---

128 * EXIT
129 * mount point is locked
130 *
131 * NOTES:
132 * A NULL path can be used for a flag since the mount
133 * system call will fail with EFAULT in copyinstr in
134 * namei() if it is a genuine NULL from the user.
135 */
102 *
103 * Called when mounting local physical media
104 *
105 * PARAMETERS:
106 * mountroot
107 * mp mount point structure
108 * path NULL (flag for root mount!!!)
109 * data <unused>

--- 19 unchanged lines hidden (view full) ---

129 * EXIT
130 * mount point is locked
131 *
132 * NOTES:
133 * A NULL path can be used for a flag since the mount
134 * system call will fail with EFAULT in copyinstr in
135 * namei() if it is a genuine NULL from the user.
136 */
136int
137ffs_mount(mp, path, data, ndp, td)
138 struct mount *mp; /* mount struct pointer*/
139 char *path; /* path to mount point*/
140 caddr_t data; /* arguments to FS specific mount*/
141 struct nameidata *ndp; /* mount point credentials*/
142 struct thread *td; /* process requesting mount*/
137static int
138ffs_omount(struct mount *mp, char *path, caddr_t data, struct thread *td)
143{
144 size_t size;
145 struct vnode *devvp, *rootvp;
146 struct ufs_args args;
147 struct ufsmount *ump = 0;
148 struct fs *fs;
149 int error, flags;
150 mode_t accessmode;
139{
140 size_t size;
141 struct vnode *devvp, *rootvp;
142 struct ufs_args args;
143 struct ufsmount *ump = 0;
144 struct fs *fs;
145 int error, flags;
146 mode_t accessmode;
147 struct nameidata ndp;
151
152 if (uma_inode == NULL) {
153 uma_inode = uma_zcreate("FFS inode",
154 sizeof(struct inode), NULL, NULL, NULL, NULL,
155 UMA_ALIGN_PTR, 0);
156 uma_ufs1 = uma_zcreate("FFS1 dinode",
157 sizeof(struct ufs1_dinode), NULL, NULL, NULL, NULL,
158 UMA_ALIGN_PTR, 0);

--- 72 unchanged lines hidden (view full) ---

231 fs->fs_ronly = 0;
232 fs->fs_clean = 0;
233 vn_finished_write(mp);
234 return (error);
235 }
236 vn_finished_write(mp);
237 }
238 if ((mp->mnt_flag & MNT_RELOAD) &&
148
149 if (uma_inode == NULL) {
150 uma_inode = uma_zcreate("FFS inode",
151 sizeof(struct inode), NULL, NULL, NULL, NULL,
152 UMA_ALIGN_PTR, 0);
153 uma_ufs1 = uma_zcreate("FFS1 dinode",
154 sizeof(struct ufs1_dinode), NULL, NULL, NULL, NULL,
155 UMA_ALIGN_PTR, 0);

--- 72 unchanged lines hidden (view full) ---

228 fs->fs_ronly = 0;
229 fs->fs_clean = 0;
230 vn_finished_write(mp);
231 return (error);
232 }
233 vn_finished_write(mp);
234 }
235 if ((mp->mnt_flag & MNT_RELOAD) &&
239 (error = ffs_reload(mp, ndp->ni_cnd.cn_cred, td)) != 0)
236 (error = ffs_reload(mp, td)) != 0)
240 return (error);
241 if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
242 /*
243 * If upgrade to read-write by non-root, then verify
244 * that user has necessary permissions on the device.
245 */
246 if (suser(td)) {
247 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);

--- 57 unchanged lines hidden (view full) ---

305 if (mp->mnt_flag & MNT_SNAPSHOT)
306 return (ffs_snapshot(mp, args.fspec));
307 }
308
309 /*
310 * Not an update, or updating the name: look up the name
311 * and verify that it refers to a sensible disk device.
312 */
237 return (error);
238 if (fs->fs_ronly && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
239 /*
240 * If upgrade to read-write by non-root, then verify
241 * that user has necessary permissions on the device.
242 */
243 if (suser(td)) {
244 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);

--- 57 unchanged lines hidden (view full) ---

302 if (mp->mnt_flag & MNT_SNAPSHOT)
303 return (ffs_snapshot(mp, args.fspec));
304 }
305
306 /*
307 * Not an update, or updating the name: look up the name
308 * and verify that it refers to a sensible disk device.
309 */
313 NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td);
314 if ((error = namei(ndp)) != 0)
310 NDINIT(&ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args.fspec, td);
311 if ((error = namei(&ndp)) != 0)
315 return (error);
312 return (error);
316 NDFREE(ndp, NDF_ONLY_PNBUF);
317 devvp = ndp->ni_vp;
313 NDFREE(&ndp, NDF_ONLY_PNBUF);
314 devvp = ndp.ni_vp;
318 if (!vn_isdisk(devvp, &error)) {
319 vrele(devvp);
320 return (error);
321 }
322
323 /*
324 * If mount by non-root, then verify that user has necessary
325 * permissions on the device.

--- 54 unchanged lines hidden (view full) ---

380 * Things to do to update the mount:
381 * 1) invalidate all cached meta-data.
382 * 2) re-read superblock from disk.
383 * 3) re-read summary information from disk.
384 * 4) invalidate all inactive vnodes.
385 * 5) invalidate all cached file data.
386 * 6) re-read inode data for all active vnodes.
387 */
315 if (!vn_isdisk(devvp, &error)) {
316 vrele(devvp);
317 return (error);
318 }
319
320 /*
321 * If mount by non-root, then verify that user has necessary
322 * permissions on the device.

--- 54 unchanged lines hidden (view full) ---

377 * Things to do to update the mount:
378 * 1) invalidate all cached meta-data.
379 * 2) re-read superblock from disk.
380 * 3) re-read summary information from disk.
381 * 4) invalidate all inactive vnodes.
382 * 5) invalidate all cached file data.
383 * 6) re-read inode data for all active vnodes.
384 */
388int
389ffs_reload(mp, cred, td)
390 struct mount *mp;
391 struct ucred *cred;
392 struct thread *td;
385static int
386ffs_reload(struct mount *mp, struct thread *td)
393{
394 struct vnode *vp, *nvp, *devvp;
395 struct inode *ip;
396 void *space;
397 struct buf *bp;
398 struct fs *fs, *newfs;
399 ufs2_daddr_t sblockloc;
400 int i, blks, size, error;
401 int32_t *lp;
402
403 if ((mp->mnt_flag & MNT_RDONLY) == 0)
404 return (EINVAL);
405 /*
406 * Step 1: invalidate all cached meta-data.
407 */
408 devvp = VFSTOUFS(mp)->um_devvp;
409 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
387{
388 struct vnode *vp, *nvp, *devvp;
389 struct inode *ip;
390 void *space;
391 struct buf *bp;
392 struct fs *fs, *newfs;
393 ufs2_daddr_t sblockloc;
394 int i, blks, size, error;
395 int32_t *lp;
396
397 if ((mp->mnt_flag & MNT_RDONLY) == 0)
398 return (EINVAL);
399 /*
400 * Step 1: invalidate all cached meta-data.
401 */
402 devvp = VFSTOUFS(mp)->um_devvp;
403 vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, td);
410 if (vinvalbuf(devvp, 0, cred, td, 0, 0) != 0)
404 if (vinvalbuf(devvp, 0, td->td_ucred, td, 0, 0) != 0)
411 panic("ffs_reload: dirty1");
412 /*
413 * Only VMIO the backing device if the backing device is a real
414 * disk device. See ffs_mountfs() for more details.
415 */
416 if (vn_isdisk(devvp, NULL))
417 vfs_object_create(devvp, td, td->td_ucred);
418 VOP_UNLOCK(devvp, 0, td);

--- 80 unchanged lines hidden (view full) ---

499 goto loop;
500 }
501 /*
502 * Step 5: invalidate all cached file data.
503 */
504 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) {
505 goto loop;
506 }
405 panic("ffs_reload: dirty1");
406 /*
407 * Only VMIO the backing device if the backing device is a real
408 * disk device. See ffs_mountfs() for more details.
409 */
410 if (vn_isdisk(devvp, NULL))
411 vfs_object_create(devvp, td, td->td_ucred);
412 VOP_UNLOCK(devvp, 0, td);

--- 80 unchanged lines hidden (view full) ---

493 goto loop;
494 }
495 /*
496 * Step 5: invalidate all cached file data.
497 */
498 if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, td)) {
499 goto loop;
500 }
507 if (vinvalbuf(vp, 0, cred, td, 0, 0))
501 if (vinvalbuf(vp, 0, td->td_ucred, td, 0, 0))
508 panic("ffs_reload: dirty2");
509 /*
510 * Step 6: re-read inode data for all active vnodes.
511 */
512 ip = VTOI(vp);
513 error =
514 bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
515 (int)fs->fs_bsize, NOCRED, &bp);

--- 1017 unchanged lines hidden ---
502 panic("ffs_reload: dirty2");
503 /*
504 * Step 6: re-read inode data for all active vnodes.
505 */
506 ip = VTOI(vp);
507 error =
508 bread(devvp, fsbtodb(fs, ino_to_fsba(fs, ip->i_number)),
509 (int)fs->fs_bsize, NOCRED, &bp);

--- 1017 unchanged lines hidden ---