Whamcloud - gitweb
Update the file size _before_ taking the read lock, or you will deadlock in
authorpschwan <pschwan>
Mon, 11 Nov 2002 18:58:58 +0000 (18:58 +0000)
committerpschwan <pschwan>
Mon, 11 Nov 2002 18:58:58 +0000 (18:58 +0000)
some contrived cases.

lustre/llite/file.c

index 3f52d6b..d6955c4 100644 (file)
@@ -431,6 +431,14 @@ static ssize_t ll_file_read(struct file *filp, char *buf, size_t count,
         ssize_t retval;
         ENTRY;
 
+        /* If we don't refresh the file size, generic_file_read may not even
+         * call us */
+        retval = ll_file_size(inode, lsm);
+        if (retval < 0) {
+                CERROR("ll_file_size: %d\n", retval);
+                RETURN(retval);
+        }
+
         if (!(fd->fd_flags & LL_FILE_IGNORE_LOCK) &&
             !(sbi->ll_flags & LL_SBI_NOLCK)) {
                 struct ldlm_extent extent;
@@ -454,14 +462,6 @@ static ssize_t ll_file_read(struct file *filp, char *buf, size_t count,
                 }
         }
 
-        /* If we don't refresh the file size, generic_file_read may not even
-         * call us */
-        retval = ll_file_size(inode, lsm);
-        if (retval < 0) {
-                CERROR("ll_file_size: %d\n", retval);
-                RETURN(retval);
-        }
-
         CDEBUG(D_INFO, "Reading inode %ld, %d bytes, offset %Ld\n",
                inode->i_ino, count, *ppos);
         retval = generic_file_read(filp, buf, count, ppos);