ffs_softdep.c (112367) | ffs_softdep.c (119521) |
---|---|
1/* 2 * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. 3 * 4 * The soft updates code is derived from the appendix of a University 5 * of Michigan technical report (Gregory R. Ganger and Yale N. Patt, 6 * "Soft Updates: A Solution to the Metadata Update Problem in File 7 * Systems", CSE-TR-254-95, August 1995). 8 * --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)ffs_softdep.c 9.59 (McKusick) 6/21/00 39 */ 40 41#include <sys/cdefs.h> | 1/* 2 * Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved. 3 * 4 * The soft updates code is derived from the appendix of a University 5 * of Michigan technical report (Gregory R. Ganger and Yale N. Patt, 6 * "Soft Updates: A Solution to the Metadata Update Problem in File 7 * Systems", CSE-TR-254-95, August 1995). 8 * --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * from: @(#)ffs_softdep.c 9.59 (McKusick) 6/21/00 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_softdep.c 112367 2003-03-18 08:45:25Z phk $"); | 42__FBSDID("$FreeBSD: head/sys/ufs/ffs/ffs_softdep.c 119521 2003-08-28 06:55:18Z jeff $"); |
43 44/* 45 * For now we want the safety net that the DIAGNOSTIC and DEBUG flags provide. 46 */ 47#ifndef DIAGNOSTIC 48#define DIAGNOSTIC 49#endif 50#ifndef DEBUG --- 4836 unchanged lines hidden (view full) --- 4887 panic("softdep_fsync_mountdev: vnode not a disk"); 4888 ACQUIRE_LOCK(&lk); 4889 VI_LOCK(vp); 4890 for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { 4891 nbp = TAILQ_NEXT(bp, b_vnbufs); 4892 /* 4893 * If it is already scheduled, skip to the next buffer. 4894 */ | 43 44/* 45 * For now we want the safety net that the DIAGNOSTIC and DEBUG flags provide. 46 */ 47#ifndef DIAGNOSTIC 48#define DIAGNOSTIC 49#endif 50#ifndef DEBUG --- 4836 unchanged lines hidden (view full) --- 4887 panic("softdep_fsync_mountdev: vnode not a disk"); 4888 ACQUIRE_LOCK(&lk); 4889 VI_LOCK(vp); 4890 for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) { 4891 nbp = TAILQ_NEXT(bp, b_vnbufs); 4892 /* 4893 * If it is already scheduled, skip to the next buffer. 4894 */ |
4895 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, 4896 VI_MTX(vp))) { 4897 VI_LOCK(vp); | 4895 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL)) |
4898 continue; | 4896 continue; |
4899 } | 4897 |
4900 if ((bp->b_flags & B_DELWRI) == 0) { 4901 FREE_LOCK(&lk); 4902 panic("softdep_fsync_mountdev: not dirty"); 4903 } 4904 /* 4905 * We are only interested in bitmaps with outstanding 4906 * dependencies. 4907 */ 4908 if ((wk = LIST_FIRST(&bp->b_dep)) == NULL || 4909 wk->wk_type != D_BMSAFEMAP || | 4898 if ((bp->b_flags & B_DELWRI) == 0) { 4899 FREE_LOCK(&lk); 4900 panic("softdep_fsync_mountdev: not dirty"); 4901 } 4902 /* 4903 * We are only interested in bitmaps with outstanding 4904 * dependencies. 4905 */ 4906 if ((wk = LIST_FIRST(&bp->b_dep)) == NULL || 4907 wk->wk_type != D_BMSAFEMAP || |
4910 (bp->b_xflags & BX_BKGRDINPROG)) { | 4908 (bp->b_vflags & BV_BKGRDINPROG)) { |
4911 BUF_UNLOCK(bp); | 4909 BUF_UNLOCK(bp); |
4912 VI_LOCK(vp); | |
4913 continue; 4914 } | 4910 continue; 4911 } |
4912 VI_UNLOCK(vp); |
|
4915 bremfree(bp); 4916 FREE_LOCK(&lk); 4917 (void) bawrite(bp); 4918 ACQUIRE_LOCK(&lk); 4919 /* 4920 * Since we may have slept during the I/O, we need 4921 * to start from a known point. 4922 */ --- 875 unchanged lines hidden (view full) --- 5798static int 5799getdirtybuf(bpp, waitfor) 5800 struct buf **bpp; 5801 int waitfor; 5802{ 5803 struct buf *bp; 5804 int error; 5805 | 4913 bremfree(bp); 4914 FREE_LOCK(&lk); 4915 (void) bawrite(bp); 4916 ACQUIRE_LOCK(&lk); 4917 /* 4918 * Since we may have slept during the I/O, we need 4919 * to start from a known point. 4920 */ --- 875 unchanged lines hidden (view full) --- 5796static int 5797getdirtybuf(bpp, waitfor) 5798 struct buf **bpp; 5799 int waitfor; 5800{ 5801 struct buf *bp; 5802 int error; 5803 |
5804 /* 5805 * XXX This code and the code that calls it need to be reviewed to 5806 * verify its use of the vnode interlock. 5807 */ 5808 |
|
5806 for (;;) { 5807 if ((bp = *bpp) == NULL) 5808 return (0); | 5809 for (;;) { 5810 if ((bp = *bpp) == NULL) 5811 return (0); |
5809 /* XXX Probably needs interlock */ | 5812 VI_LOCK(bp->b_vp); |
5810 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) { | 5813 if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) { |
5811 if ((bp->b_xflags & BX_BKGRDINPROG) == 0) | 5814 if ((bp->b_vflags & BV_BKGRDINPROG) == 0) { 5815 VI_UNLOCK(bp->b_vp); |
5812 break; | 5816 break; |
5817 } |
|
5813 BUF_UNLOCK(bp); | 5818 BUF_UNLOCK(bp); |
5814 if (waitfor != MNT_WAIT) | 5819 if (waitfor != MNT_WAIT) { 5820 VI_UNLOCK(bp->b_vp); |
5815 return (0); | 5821 return (0); |
5816 bp->b_xflags |= BX_BKGRDWAIT; 5817 interlocked_sleep(&lk, SLEEP, &bp->b_xflags, NULL, 5818 PRIBIO, "getbuf", 0); | 5822 } 5823 bp->b_vflags |= BV_BKGRDWAIT; 5824 interlocked_sleep(&lk, SLEEP, &bp->b_xflags, 5825 VI_MTX(bp->b_vp), PRIBIO|PDROP, "getbuf", 0); |
5819 continue; 5820 } | 5826 continue; 5827 } |
5828 VI_UNLOCK(bp->b_vp); |
|
5821 if (waitfor != MNT_WAIT) 5822 return (0); 5823 error = interlocked_sleep(&lk, LOCKBUF, bp, NULL, 5824 LK_EXCLUSIVE | LK_SLEEPFAIL, 0, 0); 5825 if (error != ENOLCK) { 5826 FREE_LOCK(&lk); 5827 panic("getdirtybuf: inconsistent lock"); 5828 } --- 60 unchanged lines hidden --- | 5829 if (waitfor != MNT_WAIT) 5830 return (0); 5831 error = interlocked_sleep(&lk, LOCKBUF, bp, NULL, 5832 LK_EXCLUSIVE | LK_SLEEPFAIL, 0, 0); 5833 if (error != ENOLCK) { 5834 FREE_LOCK(&lk); 5835 panic("getdirtybuf: inconsistent lock"); 5836 } --- 60 unchanged lines hidden --- |