Whamcloud - gitweb
LU-12355 llite: MS_* flags and SB_* flags split
[fs/lustre-release.git] / lustre / llite / file.c
index 87e27b5..e081f33 100644 (file)
@@ -1372,7 +1372,7 @@ static bool file_is_noatime(const struct file *file)
        if ((mnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))
                return true;
 
-       if ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))
+       if ((inode->i_sb->s_flags & SB_NODIRATIME) && S_ISDIR(inode->i_mode))
                return true;
 
        return false;
@@ -1654,6 +1654,9 @@ static ssize_t ll_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
        __u16 refcheck;
        bool cached;
 
+       if (!iov_iter_count(to))
+               return 0;
+
        /**
         * Currently when PCC read failed, we do not fall back to the
         * normal read path, just return the error.
@@ -1768,6 +1771,9 @@ static ssize_t ll_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
        ENTRY;
 
+       if (!iov_iter_count(from))
+               GOTO(out, rc_normal = 0);
+
        /**
         * When PCC write failed, we usually do not fall back to the normal
         * write path, just return the error. But there is a special case when
@@ -1866,6 +1872,9 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
        if (result)
                RETURN(result);
 
+       if (!iov_count)
+               RETURN(0);
+
 # ifdef HAVE_IOV_ITER_INIT_DIRECTION
        iov_iter_init(&to, READ, iov, nr_segs, iov_count);
 # else /* !HAVE_IOV_ITER_INIT_DIRECTION */
@@ -1883,8 +1892,12 @@ static ssize_t ll_file_read(struct file *file, char __user *buf, size_t count,
        struct iovec   iov = { .iov_base = buf, .iov_len = count };
        struct kiocb   kiocb;
        ssize_t        result;
+
        ENTRY;
 
+       if (!count)
+               RETURN(0);
+
        init_sync_kiocb(&kiocb, file);
        kiocb.ki_pos = *ppos;
 #ifdef HAVE_KIOCB_KI_LEFT
@@ -1915,6 +1928,9 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
        if (result)
                RETURN(result);
 
+       if (!iov_count)
+               RETURN(0);
+
 # ifdef HAVE_IOV_ITER_INIT_DIRECTION
        iov_iter_init(&from, WRITE, iov, nr_segs, iov_count);
 # else /* !HAVE_IOV_ITER_INIT_DIRECTION */
@@ -1936,6 +1952,9 @@ static ssize_t ll_file_write(struct file *file, const char __user *buf,
 
        ENTRY;
 
+       if (!count)
+               RETURN(0);
+
        init_sync_kiocb(&kiocb, file);
        kiocb.ki_pos = *ppos;
 #ifdef HAVE_KIOCB_KI_LEFT
@@ -4073,22 +4092,9 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end,
  * file_dentry() as is done otherwise.
  */
 
-#ifdef HAVE_FILE_FSYNC_4ARGS
 int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 {
        struct dentry *dentry = file_dentry(file);
-#elif defined(HAVE_FILE_FSYNC_2ARGS)
-int ll_fsync(struct file *file, int datasync)
-{
-       struct dentry *dentry = file_dentry(file);
-       loff_t start = 0;
-       loff_t end = LLONG_MAX;
-#else
-int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
-       loff_t start = 0;
-       loff_t end = LLONG_MAX;
-#endif
        struct inode *inode = dentry->d_inode;
        struct ll_inode_info *lli = ll_i2info(inode);
        struct ptlrpc_request *req;
@@ -4096,18 +4102,16 @@ int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
 
        ENTRY;
 
-       CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
-              PFID(ll_inode2fid(inode)), inode);
+       CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), start %lld, end %lld,"
+              "datasync %d\n",
+              PFID(ll_inode2fid(inode)), inode, start, end, datasync);
+
        ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_FSYNC, 1);
 
-#ifdef HAVE_FILE_FSYNC_4ARGS
-       rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
-       inode_lock(inode);
-#else
        /* fsync's caller has already called _fdata{sync,write}, we want
         * that IO to finish before calling the osc and mdc sync methods */
-       rc = filemap_fdatawait(inode->i_mapping);
-#endif
+       rc = filemap_write_and_wait_range(inode->i_mapping, start, end);
+       inode_lock(inode);
 
        /* catch async errors that were recorded back when async writeback
         * failed for pages in this mapping. */
@@ -4148,9 +4152,7 @@ int ll_fsync(struct file *file, struct dentry *dentry, int datasync)
                        fd->fd_write_failed = false;
        }
 
-#ifdef HAVE_FILE_FSYNC_4ARGS
        inode_unlock(inode);
-#endif
        RETURN(rc);
 }
 
@@ -4484,9 +4486,20 @@ out_iput:
 static int
 ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock)
 {
-        ENTRY;
+       struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+       ENTRY;
 
-        RETURN(-ENOSYS);
+       /*
+        * In order to avoid flood of warning messages, only print one message
+        * for one file. And the entire message rate on the client is limited
+        * by CDEBUG_LIMIT too.
+        */
+       if (!(fd->fd_flags & LL_FILE_FLOCK_WARNING)) {
+               fd->fd_flags |= LL_FILE_FLOCK_WARNING;
+               CDEBUG_LIMIT(D_TTY | D_CONSOLE,
+                            "flock disabled, mount with '-o [local]flock' to enable\r\n");
+       }
+       RETURN(-ENOSYS);
 }
 
 /**
@@ -4518,7 +4531,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, enum ldlm_mode l_req_mode)
                ldlm_lockname[mode]);
 
        flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK;
-       for (i = 0; i <= MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) {
+       for (i = 0; i < MDS_INODELOCK_NUMBITS && *bits != 0; i++) {
                policy.l_inodebits.bits = *bits & (1 << i);
                if (policy.l_inodebits.bits == 0)
                        continue;