Whamcloud - gitweb
LU-1073 llite: no CERROR on unknown flock type
[fs/lustre-release.git] / lustre / llite / file.c
index 78eb805..b4c0028 100644 (file)
@@ -318,7 +318,8 @@ int ll_file_release(struct inode *inode, struct file *file)
         /* The last ref on @file, maybe not the the owner pid of statahead.
          * Different processes can open the same dir, "ll_opendir_key" means:
          * it is me that should stop the statahead thread. */
-        if (lli->lli_opendir_key == fd && lli->lli_opendir_pid != 0)
+        if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd &&
+            lli->lli_opendir_pid != 0)
                 ll_stop_statahead(inode, lli->lli_opendir_key);
 
         if (inode->i_sb->s_root == file->f_dentry) {
@@ -327,9 +328,11 @@ int ll_file_release(struct inode *inode, struct file *file)
                 RETURN(0);
         }
 
-        if (lsm)
-                lov_test_and_clear_async_rc(lsm);
-        lli->lli_async_rc = 0;
+        if (!S_ISDIR(inode->i_mode)) {
+                if (lsm)
+                        lov_test_and_clear_async_rc(lsm);
+                lli->lli_async_rc = 0;
+        }
 
         rc = ll_md_close(sbi->ll_md_exp, inode, file);
 
@@ -519,8 +522,8 @@ int ll_file_open(struct inode *inode, struct file *file)
         fd->fd_file = file;
         if (S_ISDIR(inode->i_mode)) {
                 cfs_spin_lock(&lli->lli_sa_lock);
-                if (lli->lli_opendir_key == NULL && lli->lli_opendir_pid == 0 &&
-                    lli->lli_sai == NULL) {
+                if (lli->lli_opendir_key == NULL && lli->lli_sai == NULL &&
+                    lli->lli_opendir_pid == 0) {
                         lli->lli_opendir_key = fd;
                         lli->lli_opendir_pid = cfs_curproc_pid();
                         opendir_set = 1;
@@ -1885,7 +1888,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin)
         if (origin == 2) { /* SEEK_END */
                 int rc;
 
-                rc = cl_glimpse_size(inode);
+                rc = ll_glimpse_size(inode);
                 if (rc != 0)
                         RETURN(rc);
 
@@ -1916,6 +1919,8 @@ int ll_flush(struct file *file)
         struct lov_stripe_md *lsm = lli->lli_smd;
         int rc, err;
 
+        LASSERT(!S_ISDIR(inode->i_mode));
+
         /* the application should know write failure already. */
         if (lli->lli_write_rc)
                 return 0;
@@ -1933,9 +1938,13 @@ int ll_flush(struct file *file)
         return rc ? -EIO : 0;
 }
 
+#ifndef HAVE_FILE_FSYNC_2ARGS
 int ll_fsync(struct file *file, struct dentry *dentry, int data)
+#else
+int ll_fsync(struct file *file, int data)
+#endif
 {
-        struct inode *inode = dentry->d_inode;
+        struct inode *inode = file->f_dentry->d_inode;
         struct ll_inode_info *lli = ll_i2info(inode);
         struct lov_stripe_md *lsm = lli->lli_smd;
         struct ptlrpc_request *req;
@@ -1952,14 +1961,16 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
 
         /* catch async errors that were recorded back when async writeback
          * failed for pages in this mapping. */
-        err = lli->lli_async_rc;
-        lli->lli_async_rc = 0;
-        if (rc == 0)
-                rc = err;
-        if (lsm) {
-                err = lov_test_and_clear_async_rc(lsm);
+        if (!S_ISDIR(inode->i_mode)) {
+                err = lli->lli_async_rc;
+                lli->lli_async_rc = 0;
                 if (rc == 0)
                         rc = err;
+                if (lsm) {
+                        err = lov_test_and_clear_async_rc(lsm);
+                        if (rc == 0)
+                                rc = err;
+                }
         }
 
         oc = ll_mdscapa_get(inode);
@@ -1998,7 +2009,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data)
                         rc = err;
                 OBDO_FREE(oinfo->oi_oa);
                 OBD_FREE_PTR(oinfo);
-                lli->lli_write_rc = err < 0 ? : 0;
+                lli->lli_write_rc = rc < 0 ? rc : 0;
         }
 
         RETURN(rc);
@@ -2067,8 +2078,9 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock)
                 einfo.ei_mode = LCK_PW;
                 break;
         default:
-                CERROR("unknown fcntl lock type: %d\n", file_lock->fl_type);
-                RETURN (-EINVAL);
+                CDEBUG(D_INFO, "Unknown fcntl lock type: %d\n",
+                        file_lock->fl_type);
+                RETURN (-ENOTSUPP);
         }
 
         switch (cmd) {
@@ -2344,11 +2356,11 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it,
                 RETURN(0);
         }
 
-        /* cl_glimpse_size will prefer locally cached writes if they extend
+        /* ll_glimpse_size will prefer locally cached writes if they extend
          * the file */
 
         if (rc == 0)
-                rc = cl_glimpse_size(inode);
+                rc = ll_glimpse_size(inode);
 
         RETURN(rc);
 }