struct ll_file_data *ll_file_data_get(void)
{
- struct ll_file_data *fd;
+ struct ll_file_data *fd;
- OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, CFS_ALLOC_IO);
- return fd;
+ OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, CFS_ALLOC_IO);
+ fd->fd_write_failed = false;
+ return fd;
}
static void ll_file_data_put(struct ll_file_data *fd)
}
}
-static ssize_t ll_file_io_generic(const struct lu_env *env,
- struct vvp_io_args *args, struct file *file,
- enum cl_io_type iot, loff_t *ppos, size_t count)
+static ssize_t
+ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
+ struct file *file, enum cl_io_type iot,
+ loff_t *ppos, size_t count)
{
- struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
+ struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode);
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
struct cl_io *io;
ssize_t result;
ENTRY;
if (result >= 0) {
ll_stats_ops_tally(ll_i2sbi(file->f_dentry->d_inode),
LPROC_LL_WRITE_BYTES, result);
- lli->lli_write_rc = 0;
- } else {
- lli->lli_write_rc = result;
- }
- }
+ fd->fd_write_failed = false;
+ } else {
+ fd->fd_write_failed = true;
+ }
+ }
- return result;
+ return result;
}
int ll_flush(struct file *file, fl_owner_t id)
{
- struct inode *inode = file->f_dentry->d_inode;
- struct ll_inode_info *lli = ll_i2info(inode);
- int rc, err;
-
- LASSERT(!S_ISDIR(inode->i_mode));
+ struct inode *inode = file->f_dentry->d_inode;
+ struct ll_inode_info *lli = ll_i2info(inode);
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ int rc, err;
- /* the application should know write failure already. */
- if (lli->lli_write_rc)
- return 0;
+ LASSERT(!S_ISDIR(inode->i_mode));
- /* catch async errors that were recorded back when async writeback
- * failed for pages in this mapping. */
- rc = lli->lli_async_rc;
- lli->lli_async_rc = 0;
+ /* catch async errors that were recorded back when async writeback
+ * failed for pages in this mapping. */
+ rc = lli->lli_async_rc;
+ lli->lli_async_rc = 0;
err = lov_read_and_clear_async_rc(lli->lli_clob);
if (rc == 0)
rc = err;
+ /* The application has been told write failure already.
+ * Do not report failure again. */
+ if (fd->fd_write_failed)
+ return 0;
return rc ? -EIO : 0;
}
lsm = ccc_inode_lsm_get(inode);
if (data && lsm) {
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+
err = cl_sync_file_range(inode, 0, OBD_OBJECT_EOF,
CL_FSYNC_ALL);
if (rc == 0 && err < 0)
rc = err;
- lli->lli_write_rc = rc < 0 ? rc : 0;
+ if (rc < 0)
+ fd->fd_write_failed = true;
+ else
+ fd->fd_write_failed = false;
}
ccc_inode_lsm_put(inode, lsm);
}
#endif
-
+#ifndef HAVE_GENERIC_PERMISSION_2ARGS
static int
-#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+# ifdef HAVE_GENERIC_PERMISSION_4ARGS
lustre_check_acl(struct inode *inode, int mask, unsigned int flags)
-#else
+# else
lustre_check_acl(struct inode *inode, int mask)
-#endif
+# endif
{
-#ifdef CONFIG_FS_POSIX_ACL
- struct ll_inode_info *lli = ll_i2info(inode);
- struct posix_acl *acl;
- int rc;
- ENTRY;
+# ifdef CONFIG_FS_POSIX_ACL
+ struct ll_inode_info *lli = ll_i2info(inode);
+ struct posix_acl *acl;
+ int rc;
+ ENTRY;
-#ifdef HAVE_GENERIC_PERMISSION_4ARGS
- if (flags & IPERM_FLAG_RCU)
- return -ECHILD;
-#endif
- cfs_spin_lock(&lli->lli_lock);
- acl = posix_acl_dup(lli->lli_posix_acl);
- cfs_spin_unlock(&lli->lli_lock);
+# ifdef HAVE_GENERIC_PERMISSION_4ARGS
+ if (flags & IPERM_FLAG_RCU)
+ return -ECHILD;
+# endif
+ cfs_spin_lock(&lli->lli_lock);
+ acl = posix_acl_dup(lli->lli_posix_acl);
+ cfs_spin_unlock(&lli->lli_lock);
- if (!acl)
- RETURN(-EAGAIN);
+ if (!acl)
+ RETURN(-EAGAIN);
- rc = posix_acl_permission(inode, acl, mask);
- posix_acl_release(acl);
+ rc = posix_acl_permission(inode, acl, mask);
+ posix_acl_release(acl);
- RETURN(rc);
-#else
- return -EAGAIN;
-#endif
+ RETURN(rc);
+# else /* !CONFIG_FS_POSIX_ACL */
+ return -EAGAIN;
+# endif /* CONFIG_FS_POSIX_ACL */
}
+#endif /* HAVE_GENERIC_PERMISSION_2ARGS */
#ifdef HAVE_GENERIC_PERMISSION_4ARGS
int ll_inode_permission(struct inode *inode, int mask, unsigned int flags)