Module Name:    src
Committed By:   bouyer
Date:           Thu Feb 10 16:16:05 UTC 2011

Modified Files:
        src/sys/ufs/ufs [bouyer-quota2]: ufs_quota2.c

Log Message:
Unless the filestystem is mounted MNT_SYNCHRONOUS, use bdwrite()
to write back updated quota entries.


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.12 -r1.1.2.13 src/sys/ufs/ufs/ufs_quota2.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.1.2.12 src/sys/ufs/ufs/ufs_quota2.c:1.1.2.13
--- src/sys/ufs/ufs/ufs_quota2.c:1.1.2.12	Wed Feb  9 21:17:17 2011
+++ src/sys/ufs/ufs/ufs_quota2.c	Thu Feb 10 16:16:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.1.2.12 2011/02/09 21:17:17 bouyer Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.1.2.13 2011/02/10 16:16:05 bouyer Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -28,7 +28,7 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.1.2.12 2011/02/09 21:17:17 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.1.2.13 2011/02/10 16:16:05 bouyer Exp $");
 
 #include <sys/buf.h>
 #include <sys/param.h>
@@ -63,6 +63,7 @@
  * the locking order is dq_interlock -> dqlock
  */
 
+static int quota2_bwrite(struct mount *, struct buf *);
 static int getinoquota2(struct inode *, int, struct buf **,
     struct quota2_entry **);
 static int getq2h(struct ufsmount *, int, struct buf **,
@@ -77,6 +78,17 @@
 static const char *valtypes[] = INITQLNAMES;
 
 static int
+quota2_bwrite(struct mount *mp, struct buf *bp)
+{
+	if (mp->mnt_flag & MNT_SYNCHRONOUS)
+		return bwrite(bp);
+	else {
+		bdwrite(bp);
+		return 0;
+	}
+}
+
+static int
 getq2h(struct ufsmount *ump, int type,
     struct buf **bpp, struct quota2_header **q2hp, int flags)
 {
@@ -170,12 +182,12 @@
 			/* callback changed parent's pointer, redo */
 			off = ufs_rw64(*offp, needswap);
 			if (bp != hbp && bp != obp)
-				ret2 = VOP_BWRITE(bp);
+				ret2 = bwrite(bp);
 		} else {
 			/* parent if now current */
 			if (obp != bp && obp != hbp) {
 				if (flags & B_MODIFY)
-					ret2 = VOP_BWRITE(obp);
+					ret2 = bwrite(obp);
 				else
 					brelse(obp, 0);
 			}
@@ -192,7 +204,7 @@
 	}
 	if (obp != hbp) {
 		if (flags & B_MODIFY)
-			ret2 = VOP_BWRITE(obp);
+			ret2 = bwrite(obp);
 		else
 			brelse(obp, 0);
 	}
@@ -263,7 +275,7 @@
 		uvm_vnp_setsize(vp, ip->i_size);
 		quota2_addfreeq2e(q2h, bp->b_data, size, ump->umq2_bsize,
 		    needswap);
-		error = VOP_BWRITE(bp);
+		error = bwrite(bp);
 		error2 = UFS_UPDATE(vp, NULL, NULL, UPDATE_WAIT);
 		if (error || error2) {
 			brelse(hbp, 0);
@@ -297,7 +309,7 @@
 	q2e->q2e_next = q2h->q2h_entries[uid & hash_mask];
 	q2h->q2h_entries[uid & hash_mask] = ufs_rw64(offset, needswap);
 	if (hbp != bp) {
-		VOP_BWRITE(hbp);
+		bwrite(hbp);
 	}
 	*q2ep = q2e;
 	*bpp = bp;
@@ -404,7 +416,7 @@
 			else
 				ncurblks += change;
 			q2vp->q2v_cur = ufs_rw64(ncurblks, needswap);
-			VOP_BWRITE(bp[i]);
+			quota2_bwrite(mp, bp[i]);
 			mutex_exit(&dq->dq_interlock);
 		}
 		return 0;
@@ -479,7 +491,7 @@
 			q2vp = &q2e[i]->q2e_val[vtype];
 			ncurblks = ufs_rw64(q2vp->q2v_cur, needswap);
 			q2vp->q2v_cur = ufs_rw64(ncurblks + change, needswap);
-			VOP_BWRITE(bp[i]);
+			quota2_bwrite(mp, bp[i]);
 		} else
 			brelse(bp[i], 0);
 		mutex_exit(&dq->dq_interlock);
@@ -532,7 +544,7 @@
 		}
 		quota2_ufs_rwq2e(&q2e, &q2h->q2h_defentry, needswap);
 		mutex_exit(&dqlock);
-		VOP_BWRITE(bp);
+		quota2_bwrite(ump->um_mountp, bp);
 		goto out_wapbl;
 	}
 
@@ -560,7 +572,7 @@
 		goto out_il;
 	}
 	quota2_ufs_rwq2e(&q2e, q2ep, needswap);
-	VOP_BWRITE(bp);
+	quota2_bwrite(ump->um_mountp, bp);
 
 out_il:
 	mutex_exit(&dq->dq_interlock);
@@ -660,7 +672,7 @@
 			    q2e.q2e_val[i].q2v_grace;
 			q2ep->q2e_val[i].q2v_time = 0;
 		}
-		VOP_BWRITE(bp);
+		quota2_bwrite(ump->um_mountp, bp);
 		goto out_wapbl;
 	}
 	/* we can free it. release bp so we can walk the list */
@@ -678,7 +690,7 @@
 	    &q2h->q2h_entries[id & hash_mask], B_MODIFY, &c,
 	    dq2clear_callback);
 
-	VOP_BWRITE(hbp);
+	bwrite(hbp);
 
 out_dqlock:
 	mutex_exit(&dqlock);

Reply via email to