aboutsummaryrefslogtreecommitdiff
path: root/sys/ufs/ffs/ffs_snapshot.c
Commit message (Collapse)AuthorAgeFilesLines
* - Fix anoter dyslexic moment; an atomic_set_int should've become ACTIVESET,Jeff Roberson2005-03-011-1/+1
| | | | | | | | | not ACTIVECLEAR. Submitted by: iedowse Notes: svn path=/head/; revision=142879
* When clearing a fragment, it's possible that the length is zero.Xin LI2005-02-191-1/+1
| | | | | | | | Reviewed by: mckusick MFC After: 1 week Notes: svn path=/head/; revision=142074
* Don't use the UFS_* and VFS_* functions where a direct call is possble.Poul-Henning Kamp2005-02-081-10/+10
| | | | | | | | The UFS_ functions are for UFS to call back into VFS. The VFS functions are external entry points into the filesystem. Notes: svn path=/head/; revision=141526
* For snapshots we need all VOP_LOCKs to be exclusive.Poul-Henning Kamp2005-02-081-9/+9
| | | | | | | | | | | | | | The "business class upgrade" was implemented in UFS's VOP_LOCK implementation ufs_lock() which is the wrong layer, so move it to ffs_lock(). Also, as long as we have not abandonned advanced vfs-stacking we should not preclude it from happening: instead of implementing a copy locally, use the VOP_LOCK_APV(&ufs) to correctly arrive at vop_stdlock() at the bottom. Notes: svn path=/head/; revision=141522
* - Use the ufs lock to protect fs_active.Jeff Roberson2005-01-241-10/+26
| | | | | | | Sponsored By: Isilon Systems, Inc. Notes: svn path=/head/; revision=140706
* Remove the unused credential argument from VOP_FSYNC() and VFS_SYNC().Poul-Henning Kamp2005-01-111-9/+9
| | | | | | | | | | | | | | | | | | | | | I'm not sure why a credential was added to these in the first place, it is not used anywhere and it doesn't make much sense: The credentials for syncing a file (ability to write to the file) should be checked at the system call level. Credentials for syncing one or more filesystems ("none") should be checked at the system call level as well. If the filesystem implementation needs a particular credential to carry out the syncing it would logically have to the cached mount credential, or a credential cached along with any delayed write data. Discussed with: rwatson Notes: svn path=/head/; revision=140048
* /* -> /*- for license, minor formatting changesWarner Losh2005-01-071-1/+1
| | | | Notes: svn path=/head/; revision=139825
* Fixes a bug that caused UFS2 filesystems bigger than 2TB toKirk McKusick2004-12-091-1/+1
| | | | | | | | | | | prematurely report that they were full and/or to panic the kernel with the message ``ffs_clusteralloc: allocated out of group''. Submitted by: Henry Whincup <henry@jot.to> MFC after: 1 week Notes: svn path=/head/; revision=138634
* Fix snapshot creation.Poul-Henning Kamp2004-12-081-1/+1
| | | | Notes: svn path=/head/; revision=138557
* Move UFS from DEVFS backing to GEOM backing.Poul-Henning Kamp2004-10-291-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This eliminates a bunch of vnode overhead (approx 1-2 % speed improvement) and gives us more control over the access to the storage device. Access counts on the underlying device are not correctly tracked and therefore it is possible to read-only mount the same disk device multiple times: syv# mount -p /dev/md0 /var ufs rw 2 2 /dev/ad0 /mnt ufs ro 1 1 /dev/ad0 /mnt2 ufs ro 1 1 /dev/ad0 /mnt3 ufs ro 1 1 Since UFS/FFS is not a synchrousely consistent filesystem (ie: it caches things in RAM) this is not possible with read-write mounts, and the system will correctly reject this. Details: Add a geom consumer and a bufobj pointer to ufsmount. Eliminate the vnode argument from softdep_disk_prewrite(). Pick the vnode out of bp->b_vp for now. Eventually we should find it through bp->b_bufobj->b_private. In the mountcode, use g_vfs_open() once we have used VOP_ACCESS() to check permissions. When upgrading and downgrading between r/o and r/w do the right thing with GEOM access counts. Remove all the workarounds for not being able to do this with VOP_OPEN(). If we are the root mount, drop the exclusive access count until we upgrade to r/w. This allows fsck of the root filesystem and the MNT_RELOAD to work correctly. Set bo_private to the GEOM consumer on the device bufobj. Change the ffs_ops->strategy function to call g_vfs_strategy() In ufs_strategy() directly call the strategy on the disk bufobj. Same in rawread. In ffs_fsync() we will no longer see VCHR device nodes, so remove code which synced the filesystem mounted on it, in case we came there. I'm not sure this code made sense in the first place since we would have taken the specfs route on such a vnode. Redo the highly bogus readblock() function in the snapshot code to something slightly less bogus: Constructing an uio and using physio was really quite a detour. Instead just fill in a bio and ship it down. Notes: svn path=/head/; revision=137035
* Degeneralize the per cdev copyonwrite callback. The only possible valuePoul-Henning Kamp2004-10-261-6/+1
| | | | | | | | | is ffs_copyonwrite() and the only place it can be called from is FFS which would never want to call another filesystems copyonwrite method, should one exist, so there is no reason why anything generic should know about this. Notes: svn path=/head/; revision=136963
* Do not traverse list of snapshots if there isn't one.Poul-Henning Kamp2004-09-161-0/+4
| | | | | | | Found by: scottl Notes: svn path=/head/; revision=135312
* Missed a place where snapshots were allocated in my last commit toPoul-Henning Kamp2004-09-161-11/+8
| | | | | | | this file. Notes: svn path=/head/; revision=135303
* Create struct snapdata which contains the snapshot fields from cdevPoul-Henning Kamp2004-09-131-70/+88
| | | | | | | | | | | | | | and the previously malloc'ed snapshot lock. Malloc struct snapdata instead of just the lock. Replace snapshot fields in cdev with pointer to snapdata (saves 16 bytes). While here, give the private readblock() function a vnode argument in preparation for moving UFS to access GEOM directly. Notes: svn path=/head/; revision=135138
* Avoid using casts as lvalues. Introduce DIP_SET macro which sets properAlexander Kabaev2004-07-281-13/+14
| | | | | | | | inode field based on UFS version. Use DIP ro read values and DIP_SET to modify them throughout FFS code base. Notes: svn path=/head/; revision=132775
* When we traverse the vnodes on a mountpoint we need to look out forPoul-Henning Kamp2004-07-041-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | our cached 'next vnode' being removed from this mountpoint. If we find that it was recycled, we restart our traversal from the start of the list. Code to do that is in all local disk filesystems (and a few other places) and looks roughly like this: MNT_ILOCK(mp); loop: for (vp = TAILQ_FIRST(&mp...); (vp = nvp) != NULL; nvp = TAILQ_NEXT(vp,...)) { if (vp->v_mount != mp) goto loop; MNT_IUNLOCK(mp); ... MNT_ILOCK(mp); } MNT_IUNLOCK(mp); The code which takes vnodes off a mountpoint looks like this: MNT_ILOCK(vp->v_mount); ... TAILQ_REMOVE(&vp->v_mount->mnt_nvnodelist, vp, v_nmntvnodes); ... MNT_IUNLOCK(vp->v_mount); ... vp->v_mount = something; (Take a moment and try to spot the locking error before you read on.) On a SMP system, one CPU could have removed nvp from our mountlist but not yet gotten to assign a new value to vp->v_mount while another CPU simultaneously get to the top of the traversal loop where it finds that (vp->v_mount != mp) is not true despite the fact that the vnode has indeed been removed from our mountpoint. Fix: Introduce the macro MNT_VNODE_FOREACH() to traverse the list of vnodes on a mountpoint while taking into account that vnodes may be removed from the list as we go. This saves approx 65 lines of duplicated code. Split the insmntque() which potentially moves a vnode from one mount point to another into delmntque() and insmntque() which does just what the names say. Fix delmntque() to set vp->v_mount to NULL while holding the mountpoint lock. Notes: svn path=/head/; revision=131551
* Avoid deadlock which is caused by locking VDIR of parent and VREG ofJun Kuriyama2004-06-181-0/+9
| | | | | | | | | | | snapshot itself in wrong order. We can skip unlink check of that directory because it must have snapshot in it. Reviewed by: mckusick and current@ Notes: svn path=/head/; revision=130690
* Nice, is a property of a process as a whole..Julian Elischer2004-06-161-4/+4
| | | | | | | | I mistakenly moved it to the ksegroup when breaking up the process structure. Put it back in the proc structure. Notes: svn path=/head/; revision=130551
* Avoid assignments to cast expressions.Stefan Farfeleder2004-06-081-2/+2
| | | | | | | | Reviewed by: md5 Approved by: das (mentor) Notes: svn path=/head/; revision=130246
* Fix style bugs in previous commit.Jun Kuriyama2004-02-131-2/+6
| | | | | | | Submitted by: bde Notes: svn path=/head/; revision=125764
* Reverse lock order by using local variable. This will shut up "acquiringJun Kuriyama2004-02-121-4/+6
| | | | | | | | | duplicate lock of same type" message. Reviewed by: mckusick Notes: svn path=/head/; revision=125732
* Avoid calling vprint on a vnode while holding its interlock mutex.Alexander Kabaev2004-01-041-2/+2
| | | | | | | | | Move diagnostic printf after vget. This might delay the debug output some, but at least it keeps kernel from exploding if DEBUG_VFS_LOCKS is in effect. Notes: svn path=/head/; revision=124119
* Call free(9) after the vnode interlock is released, avoiding a lock-orderAlan Cox2003-11-131-1/+1
| | | | | | | reversal. Notes: svn path=/head/; revision=122596
* Remove mntvnode_mtx and replace it with per-mountpoint mutex.Alexander Kabaev2003-11-051-8/+8
| | | | | | | | | | | | | Introduce two new macros MNT_ILOCK(mp)/MNT_IUNLOCK(mp) to operate on this mutex transparently. Eventually new mutex will be protecting more fields in struct mount, not only vnode list. Discussed with: jeff Notes: svn path=/head/; revision=122091
* Move the P_COWINPROGRESS flag from being a per-process p_flag to being aJohn Baldwin2003-10-231-13/+13
| | | | | | | | | | per-thread td_pflag which doesn't require any locks to read or write as it is only read or written by curthread on itself. Glanced at by: mckusick Notes: svn path=/head/; revision=121443
* When expunging unlinked files from a snapshot, skip over holes in theKirk McKusick2003-10-171-6/+16
| | | | | | | | | file rather than panicing with "indiracct: botched params". Submitted by: Mark Santcroos <marks@ripe.net> Notes: svn path=/head/; revision=121158
* - Skip over xvp if XLOCK is set.Jeff Roberson2003-10-051-1/+2
| | | | Notes: svn path=/head/; revision=120789
* - Fix an unlocked call to GETATTR by slightly shuffling the code inJeff Roberson2003-10-041-6/+14
| | | | | | | | | ffs_snapshot() around. - Acquire the interlock before releasing the mntvnode_mtx. Use the interlock to protect v_usecount access. Notes: svn path=/head/; revision=120740
* Use __FBSDID().David E. O'Brien2003-06-111-1/+3
| | | | Notes: svn path=/head/; revision=116192
* Fix some easy, global, lint warnings. In most cases, this meansMark Murray2003-04-301-1/+1
| | | | | | | | making some local variables static. In a couple of cases, this means removing an unused variable. Notes: svn path=/head/; revision=114293
* Lock both the proc lock and sched_lock when calling sched_nice sinceJohn Baldwin2003-04-221-1/+10
| | | | | | | | | kg_nice is now protected by both. Being protected by both means that other places in the kernel that want to read kg_nice only need one of the two locks. Notes: svn path=/head/; revision=113872
* - Use the sched_nice() api instead of setting the nice value directly.Jeff Roberson2003-04-121-2/+3
| | | | | | | Tested by: Steve Kargl <sgk@troutmask.apl.washington.edu> Notes: svn path=/head/; revision=113376
* Use td->td_ucred instead of td->td_proc->p_ucred.John Baldwin2003-03-201-1/+1
| | | | Notes: svn path=/head/; revision=112451
* Including <sys/stdint.h> is (almost?) universally only to be able to usePoul-Henning Kamp2003-03-181-1/+0
| | | | | | | | %j in printfs, so put a newsted include in <sys/systm.h> where the printf prototype lives and save everybody else the trouble. Notes: svn path=/head/; revision=112367
* Use the appropriate size when zeroing out the unused portionKirk McKusick2003-03-071-3/+3
| | | | | | | | | | | of a snapshot's copy of a superblock. This patch fixes a panic when taking a snapshot of a 4096/512 filesystem. Reported by: Ian Freislich <ianf@za.uu.net> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=111972
* - Add a new 'flags' parameter to getblk().Jeff Roberson2003-03-041-2/+2
| | | | | | | | | | | | | - Define one flag GB_LOCK_NOWAIT that tells getblk() to pass the LK_NOWAIT flag to the initial BUF_LOCK(). This will eventually be used in cases were we want to use a buffer only if it is not currently in use. - Convert all consumers of the getblk() api to use this extra parameter. Reviwed by: arch Not objected to by: mckusick Notes: svn path=/head/; revision=111856
* This patch fixes a deadlock between the bufdaemon and a process takingKirk McKusick2003-02-221-7/+43
| | | | | | | | | | | | | | | | | | | | | a snapshot. As part of taking a snapshot of a filesystem, the kernel builds up a list of the filesystem metadata (such as the cylinder group bitmaps) that are contained in the snapshot. When doing a copy-on-write check, the list is first consulted. If the block being written is found on the list, then the full snapshot lookup can be avoided. Besides providing an important performance speedup this check also avoids a potential deadlock between the code creating the snapshot and the bufdaemon trying to cleanup snapshot related buffers. This fix creates a temporary list containing the key metadata blocks that can cause the deadlock. This temporary list is used between the time that the snapshot is first enabled and the time that the fully complete list is built. Reported by: Attila Nagy <bra@fsn.hu> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=111240
* This patch fixes a bug on an active filesystem on which a snapshotKirk McKusick2003-02-221-0/+4
| | | | | | | | | | | | | | | | | is being taken from panicing with either "freeing free block" or "freeing free inode". The problem arises when the snapshot code is scanning the filesystem looking for inodes with a reference count of zero (e.g., unlinked but still open) so that it can expunge them from its view. If it encounters a reclaimed vnode and has to restart its scan, then it will panic if it encounters and tries to free an inode that it has already processed. The fix is to check each candidate inode to see if it has already been processed before trying to delete it from the snapshot image. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=111239
* This patch fixes a bug in the logical block calculation macros soKirk McKusick2003-02-221-3/+3
| | | | | | | | | | that they convert to 64-bit values before shifting rather than afterwards. Once fixed, they can be used rather than inline expanded. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=111238
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-8/+8
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-8/+8
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Fix corruption introduced in previous delta.Kirk McKusick2002-12-181-4/+12
| | | | | | | | Reported by: Aurelien Nephtali <aurelien.nephtali@wanadoo.fr> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=108050
* Keep comments consistent with the code. Minor optimization.Kirk McKusick2002-12-181-14/+4
| | | | | | | Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=108017
* Update to previous change (1.54) to use an approperly wide inode fieldKirk McKusick2002-12-151-8/+6
| | | | | | | | | | | so as to work correctly on 64-bit platforms. Reported-by: Jake Burkholder <jake@locore.ca> Sponsored by: DARPA & NAI Labs. Approved by: Ian Dowse <iedowse@maths.tcd.ie> Notes: svn path=/head/; revision=107915
* Only the most recent snapshot contains the complete list of blocksKirk McKusick2002-12-141-138/+188
| | | | | | | | | | | | | | that were copied in all of the earlier snapshots, thus its precomputed list must be used in the copyonwrite test. Using incomplete lists may lead to deadlock. Also do not include the blocks used for the indirect pointers in the indirect pointers as this may lead to inconsistent snapshots. Sponsored by: DARPA & NAI Labs. Approved by: re Notes: svn path=/head/; revision=107848
* Have to use bread() rather than UFS_BALLOC() when obtaining aKirk McKusick2002-12-031-24/+30
| | | | | | | | | | | | | | previously allocated block as the previous use of the block may have fallen out of the cache. Failure to reread its contents cause zeroed results to be written instead of the proper contents. Conversely, when the block is going to be entirely filled in, it is not necessary reread the old contents. Sponsored by: DARPA & NAI Labs. Approved by: re Notes: svn path=/head/; revision=107558
* Remove a race condition / deadlock from snapshots. WhenKirk McKusick2002-11-301-54/+112
| | | | | | | | | | | | | | | converting from individual vnode locks to the snapshot lock, be sure to pass any waiting processes along to the new lock as well. This transfer is done by a new function in the lock manager, transferlockers(from_lock, to_lock); Thanks to Lamont Granquist <lamont@scriptkiddie.org> for his help in pounding on snapshots beyond all reason and finding this deadlock. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107414
* Fix two deadlocks in snapshots:Kirk McKusick2002-11-301-2/+7
| | | | | | | | | | | | | | | | | | | 1) Release the snapshot file lock while suspending the system. Otherwise a process trying to read the lock may block on its containing directory preventing the suspension from completing. Thanks to Sean Kelly <smkelly@zombie.org> for finding this deadlock. 2) Replace some bdwrite's with bawrite's so as not to fill all the buffers with dirty data. The buffers could not be cleaned as the snapshot vnode was locked hence the system could deadlock when making snapshots of really massive filesystems. Thanks to Hidetoshi Shimokawa <simokawa@sat.t.u-tokyo.ac.jp> for figuring this out. Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107406
* Create a new 32-bit fs_flags word in the superblock. Add code to moveKirk McKusick2002-11-271-4/+4
| | | | | | | | | | | | | | | | | | | | the old 8-bit fs_old_flags to the new location the first time that the filesystem is mounted by a new kernel. One of the unused flags in fs_old_flags is used to indicate that the flags have been moved. Leave the fs_old_flags word intact so that it will work properly if used on an old kernel. Change the fs_sblockloc superblock location field to be in units of bytes instead of in units of filesystem fragments. The old units did not work properly when the fragment size exceeeded the superblock size (8192). Update old fs_sblockloc values at the same time that the flags are moved. Suggested by: BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs. Notes: svn path=/head/; revision=107294
* Do not assume that time_t is an int.Peter Wemm2002-11-151-2/+2
| | | | | | | Approved by: re (jhb) Notes: svn path=/head/; revision=106965