/* also used by llite/special.c:ll_special_open() */
struct ll_file_data *ll_file_data_get(void)
{
- struct ll_file_data *fd;
+ struct ll_file_data *fd;
- OBD_SLAB_ALLOC_PTR(fd, ll_file_data_slab);
- return fd;
+ OBD_SLAB_ALLOC_PTR(fd, ll_file_data_slab);
+ fd->fd_write_failed = false;
+ return fd;
}
static void ll_file_data_put(struct ll_file_data *fd)
unsigned long nrsegs_copy, nrsegs_orig = 0;
size_t count, iov_offset = 0;
int got_write_sem = 0;
- struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
ENTRY;
count = ll_file_get_iov_count(iov, &nr_segs);
retval = (sum > 0) ? sum : retval;
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_WRITE_BYTES,
retval > 0 ? retval : 0);
+ if (retval < 0)
+ fd->fd_write_failed = true;
+ else
+ fd->fd_write_failed = false;
RETURN(retval);
}
int ll_flush(struct file *file)
#endif
{
- struct inode *inode = file->f_dentry->d_inode;
- struct ll_inode_info *lli = ll_i2info(inode);
- struct lov_stripe_md *lsm = lli->lli_smd;
- int rc, err;
-
- /* 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;
- if (lsm) {
- err = lov_test_and_clear_async_rc(lsm);
- if (rc == 0)
- rc = err;
- }
-
- return rc ? -EIO : 0;
+ 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 ll_file_data *fd = LUSTRE_FPRIVATE(file);
+ int rc, err;
+
+ /* 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;
+ if (lsm) {
+ err = lov_test_and_clear_async_rc(lsm);
+ 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;
}
int ll_fsync(struct file *file, struct dentry *dentry, int data)
if (data && lsm) {
struct obd_info *oinfo;
+ struct ll_file_data *fd = LUSTRE_FPRIVATE(file);
OBD_ALLOC_PTR(oinfo);
if (!oinfo)
rc = err;
OBDO_FREE(oinfo->oi_oa);
OBD_FREE_PTR(oinfo);
+ if (rc < 0)
+ fd->fd_write_failed = true;
+ else
+ fd->fd_write_failed = false;
}
RETURN(rc);