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;
}
RETURN(rc);
}
-int ll_fid2path(struct obd_export *exp, void *arg)
+int ll_fid2path(struct inode *inode, void *arg)
{
+ struct obd_export *exp = ll_i2mdexp(inode);
struct getinfo_fid2path *gfout, *gfin;
int outsize, rc;
ENTRY;
+ if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) &&
+ !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
+ RETURN(-EPERM);
+
/* Need to get the buflen */
OBD_ALLOC_PTR(gfin);
if (gfin == NULL)
RETURN(0);
}
case OBD_IOC_FID2PATH:
- RETURN(ll_fid2path(ll_i2mdexp(inode), (void *)arg));
+ RETURN(ll_fid2path(inode, (void *)arg));
case LL_IOC_DATA_VERSION: {
struct ioc_data_version idv;
int rc;
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);
}
flock.l_flock.pid = file_lock->fl_pid;
- /* Somewhat ugly workaround for svc lockd.
- * lockd installs custom fl_lmops->fl_compare_owner that checks
- * for the fl_owner to be the same (which it always is on local node
- * I guess between lockd processes) and then compares pid.
- * As such we assign pid to the owner field to make it all work,
- * conflict with normal locks is unlikely since pid space and
- * pointer space for current->files are not intersecting */
- if (file_lock->fl_lmops && file_lock->fl_lmops->fl_compare_owner)
- flock.l_flock.owner = (unsigned long)file_lock->fl_pid;
+ /* Somewhat ugly workaround for svc lockd.
+ * lockd installs custom fl_lmops->lm_compare_owner that checks
+ * for the fl_owner to be the same (which it always is on local node
+ * I guess between lockd processes) and then compares pid.
+ * As such we assign pid to the owner field to make it all work,
+ * conflict with normal locks is unlikely since pid space and
+ * pointer space for current->files are not intersecting */
+ if (file_lock->fl_lmops && file_lock->fl_lmops->lm_compare_owner)
+ flock.l_flock.owner = (unsigned long)file_lock->fl_pid;
switch (file_lock->fl_type) {
case F_RDLCK: