patch-2.2.18 linux/fs/dquot.c

Next file: linux/fs/exec.c
Previous file: linux/fs/buffer.c
Back to the patch index
Back to the overall index

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/fs/dquot.c linux/fs/dquot.c
@@ -1265,14 +1265,6 @@
 	if (!inode)
 		return -ENOENT;
 	/*
-	 * Find out if this filesystem uses i_blocks.
-	 */
-	if (inode->i_blksize == 0)
-		blocks = isize_to_blocks(inode->i_size, BLOCK_SIZE);
-	else
-		blocks = (inode->i_blocks / 2);
-
-	/*
 	 * Build the transfer_from and transfer_to lists and check quotas to see
 	 * if operation is permitted.
 	 */
@@ -1331,14 +1323,29 @@
 		 * dqget() could block and so the first structure might got
 		 * invalidated or locked...
 		 */
-		if (!transfer_to[cnt]->dq_mnt || !transfer_from[cnt]->dq_mnt ||
-		    check_idq(transfer_to[cnt], cnt, 1, initiator, tty) == NO_QUOTA ||
-		    check_bdq(transfer_to[cnt], cnt, blocks, initiator, tty, 0) == NO_QUOTA) {
+		if (!transfer_to[cnt]->dq_mnt || !transfer_from[cnt]->dq_mnt) {
 			cnt++;
 			goto put_all;
 		}
 	}
 
+	/*
+	 * Find out if this filesystem uses i_blocks.
+	 */
+	if (inode->i_blksize == 0)
+		blocks = isize_to_blocks(inode->i_size, BLOCK_SIZE);
+	else
+		blocks = (inode->i_blocks / 2);
+	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
+	{
+		if (transfer_to[cnt] == NODQUOT)
+			continue;
+		if (check_idq(transfer_to[cnt], cnt, 1, initiator, tty) == NO_QUOTA ||
+		    check_bdq(transfer_to[cnt], cnt, blocks, initiator, tty, 0) == NO_QUOTA) {
+			cnt = MAXQUOTAS;
+			goto put_all;
+		}
+}
 	if ((error = notify_change(dentry, iattr)))
 		goto put_all; 
 	/*
@@ -1521,7 +1528,7 @@
 	if (IS_ERR(f))
 		goto out_lock;
 	error = -EIO;
-	if (!f->f_op->read && !f->f_op->write)
+	if (!f->f_op || (!f->f_op->read && !f->f_op->write))
 		goto out_f;
 	inode = f->f_dentry->d_inode;
 	error = -EACCES;

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