patch-2.3.7 linux/fs/sysv/truncate.c

Next file: linux/fs/ufs/file.c
Previous file: linux/fs/sysv/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.6/linux/fs/sysv/truncate.c linux/fs/sysv/truncate.c
@@ -35,6 +35,9 @@
  * general case (size = XXX). I hope.
  */
 
+#define DATA_BUFFER_USED(bh) \
+	((bh->b_count > 1) || buffer_locked(bh))
+
 /* We throw away any data beyond inode->i_size. */
 
 static int trunc_direct(struct inode * inode)
@@ -58,7 +61,7 @@
 			brelse(bh);
 			goto repeat;
 		}
-		if ((bh && bh->b_count != 1) || (block != *p)) {
+		if ((bh && DATA_BUFFER_USED(bh)) || (block != *p)) {
 			retry = 1;
 			brelse(bh);
 			continue;
@@ -115,7 +118,7 @@
 			brelse(bh);
 			goto repeat;
 		}
-		if ((bh && bh->b_count != 1) || (tmp != *ind)) {
+		if ((bh && DATA_BUFFER_USED(bh)) || (tmp != *ind)) {
 			retry = 1;
 			brelse(bh);
 			continue;
@@ -128,7 +131,7 @@
 	for (i = 0; i < sb->sv_ind_per_block; i++)
 		if (((sysv_zone_t *) indbh->b_data)[i])
 			goto done;
-	if ((indbh->b_count != 1) || (indtmp != *p)) {
+	if (DATA_BUFFER_USED(indbh) || (indtmp != *p)) {
 		brelse(indbh);
 		return 1;
 	}
@@ -185,7 +188,7 @@
 	for (i = 0; i < sb->sv_ind_per_block; i++)
 		if (((sysv_zone_t *) indbh->b_data)[i])
 			goto done;
-	if ((indbh->b_count != 1) || (indtmp != *p)) {
+	if (DATA_BUFFER_USED(indbh) || (indtmp != *p)) {
 		brelse(indbh);
 		return 1;
 	}
@@ -242,7 +245,7 @@
 	for (i = 0; i < sb->sv_ind_per_block; i++)
 		if (((sysv_zone_t *) indbh->b_data)[i])
 			goto done;
-	if ((indbh->b_count != 1) || (indtmp != *p)) {
+	if (DATA_BUFFER_USED(indbh) || (indtmp != *p)) {
 		brelse(indbh);
 		return 1;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)