* If \a bias is MDS_CLOSE_LAYOUT_SWAP then \a data is a pointer to the inode to
* swap layouts with.
*/
-static int ll_close_inode_openhandle(struct obd_export *md_exp,
+static int ll_close_inode_openhandle(struct inode *inode,
struct obd_client_handle *och,
- struct inode *inode,
enum mds_op_bias bias, void *data)
{
+ struct obd_export *md_exp = ll_i2mdexp(inode);
const struct ll_inode_info *lli = ll_i2info(inode);
struct md_op_data *op_data;
struct ptlrpc_request *req = NULL;
if (och != NULL) {
/* There might be a race and this handle may already
* be closed. */
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp,
- och, inode, 0, NULL);
+ rc = ll_close_inode_openhandle(inode, och, 0, NULL);
}
RETURN(rc);
}
-static int ll_md_close(struct obd_export *md_exp, struct inode *inode,
- struct file *file)
+static int ll_md_close(struct inode *inode, struct file *file)
{
union ldlm_policy_data policy = {
.l_inodebits = { MDS_INODELOCK_OPEN },
}
if (fd->fd_och != NULL) {
- rc = ll_close_inode_openhandle(md_exp, fd->fd_och, inode, 0,
- NULL);
+ rc = ll_close_inode_openhandle(inode, fd->fd_och, 0, NULL);
fd->fd_och = NULL;
GOTO(out, rc);
}
}
mutex_unlock(&lli->lli_och_mutex);
- if (!md_lock_match(md_exp, flags, ll_inode2fid(inode),
+ if (!md_lock_match(ll_i2mdexp(inode), flags, ll_inode2fid(inode),
LDLM_IBITS, &policy, lockmode, &lockh))
rc = ll_md_real_close(inode, fd->fd_omode);
ll_deauthorize_statahead(inode, fd);
if (inode->i_sb->s_root == file->f_path.dentry) {
- LUSTRE_FPRIVATE(file) = NULL;
- ll_file_data_put(fd);
- RETURN(0);
- }
+ LUSTRE_FPRIVATE(file) = NULL;
+ ll_file_data_put(fd);
+ RETURN(0);
+ }
- if (!S_ISDIR(inode->i_mode)) {
+ if (!S_ISDIR(inode->i_mode)) {
if (lli->lli_clob != NULL)
lov_read_and_clear_async_rc(lli->lli_clob);
- lli->lli_async_rc = 0;
- }
+ lli->lli_async_rc = 0;
+ }
- rc = ll_md_close(sbi->ll_md_exp, inode, file);
+ rc = ll_md_close(inode, file);
- if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val))
- libcfs_debug_dumplog();
+ if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val))
+ libcfs_debug_dumplog();
- RETURN(rc);
+ RETURN(rc);
}
static int ll_intent_file_open(struct file *file, void *lmm, int lmmsize,
it.d.lustre.it_lock_mode = 0;
och->och_lease_handle.cookie = 0ULL;
}
- rc2 = ll_close_inode_openhandle(sbi->ll_md_exp, och, inode, 0, NULL);
+ rc2 = ll_close_inode_openhandle(inode, och, 0, NULL);
if (rc2 < 0)
CERROR("%s: error closing file "DFID": %d\n",
ll_get_fsname(inode->i_sb, NULL, 0),
/* Close the file and swap layouts between inode & inode2.
* NB: lease lock handle is released in mdc_close_layout_swap_pack()
* because we still need it to pack l_remote_handle to MDT. */
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, och, inode,
- MDS_CLOSE_LAYOUT_SWAP, inode2);
+ rc = ll_close_inode_openhandle(inode, och, MDS_CLOSE_LAYOUT_SWAP,
+ inode2);
och = NULL; /* freed in ll_close_inode_openhandle() */
if (lease_broken != NULL)
*lease_broken = cancelled;
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, och, inode,
- 0, NULL);
-
+ rc = ll_close_inode_openhandle(inode, och, 0, NULL);
RETURN(rc);
}
ll_stats_ops_tally(ll_i2sbi(inode),
LPROC_LL_WRITE_BYTES, result);
fd->fd_write_failed = false;
+ } else if (result == 0 && rc == 0) {
+ rc = io->ci_result;
+ if (rc < 0)
+ fd->fd_write_failed = true;
+ else
+ fd->fd_write_failed = false;
} else if (rc != -ERESTARTSYS) {
fd->fd_write_failed = true;
}
struct vvp_io_args *args;
struct lu_env *env;
ssize_t result;
- int refcheck;
+ __u16 refcheck;
env = cl_env_get(&refcheck);
if (IS_ERR(env))
struct vvp_io_args *args;
struct lu_env *env;
ssize_t result;
- int refcheck;
+ __u16 refcheck;
env = cl_env_get(&refcheck);
if (IS_ERR(env))
struct iov_iter *to;
size_t iov_count;
ssize_t result;
+ struct lu_env *env = NULL;
+ __u16 refcheck;
ENTRY;
result = ll_file_get_iov_count(iov, &nr_segs, &iov_count);
RETURN(result);
if (nr_segs == 1) {
- struct lu_env *env;
- int refcheck;
env = cl_env_get(&refcheck);
if (IS_ERR(env))
local_iov = &ll_env_info(env)->lti_local_iov;
*local_iov = *iov;
- cl_env_put(env, &refcheck);
} else {
OBD_ALLOC(local_iov, sizeof(*iov) * nr_segs);
if (local_iov == NULL)
OBD_FREE_PTR(to);
out:
- if (nr_segs > 1)
+ if (nr_segs == 1)
+ cl_env_put(env, &refcheck);
+ else
OBD_FREE(local_iov, sizeof(*iov) * nr_segs);
RETURN(result);
struct iovec iov = { .iov_base = buf, .iov_len = count };
struct kiocb *kiocb;
ssize_t result;
- int refcheck;
+ __u16 refcheck;
ENTRY;
env = cl_env_get(&refcheck);
struct iov_iter *from;
size_t iov_count;
ssize_t result;
+ struct lu_env *env = NULL;
+ __u16 refcheck;
ENTRY;
result = ll_file_get_iov_count(iov, &nr_segs, &iov_count);
RETURN(result);
if (nr_segs == 1) {
- struct lu_env *env;
- int refcheck;
-
env = cl_env_get(&refcheck);
if (IS_ERR(env))
RETURN(PTR_ERR(env));
local_iov = &ll_env_info(env)->lti_local_iov;
*local_iov = *iov;
-
- cl_env_put(env, &refcheck);
} else {
OBD_ALLOC(local_iov, sizeof(*iov) * nr_segs);
if (local_iov == NULL)
OBD_FREE_PTR(from);
out:
- if (nr_segs > 1)
+ if (nr_segs == 1)
+ cl_env_put(env, &refcheck);
+ else
OBD_FREE(local_iov, sizeof(*iov) * nr_segs);
RETURN(result);
.iov_len = count };
struct kiocb *kiocb;
ssize_t result;
- int refcheck;
+ __u16 refcheck;
ENTRY;
env = cl_env_get(&refcheck);
struct lu_env *env;
struct vvp_io_args *args;
ssize_t result;
- int refcheck;
+ __u16 refcheck;
ENTRY;
env = cl_env_get(&refcheck);
struct lov_user_md __user *lum)
{
struct lu_env *env;
- int refcheck;
+ __u16 refcheck;
int rc;
ENTRY;
ll_och_fill(ll_i2sbi(inode)->ll_md_exp, it, och);
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp,
- och, inode, 0, NULL);
+ rc = ll_close_inode_openhandle(inode, och, 0, NULL);
out:
/* this one is in place of ll_file_open */
if (it_disposition(it, DISP_ENQ_OPEN_REF)) {
size_t num_bytes)
{
struct lu_env *env;
- int refcheck;
+ __u16 refcheck;
int rc = 0;
struct ll_fiemap_info_key fmkey = { .lfik_name = KEY_FIEMAP, };
ENTRY;
struct cl_object *obj = ll_i2info(inode)->lli_clob;
struct lu_env *env;
struct cl_io *io;
- int refcheck;
+ __u16 refcheck;
int result;
ENTRY;
/* Release the file.
* NB: lease lock handle is released in mdc_hsm_release_pack() because
* we still need it to pack l_remote_handle to MDT. */
- rc = ll_close_inode_openhandle(ll_i2sbi(inode)->ll_md_exp, och, inode,
- MDS_HSM_RELEASE, &data_version);
+ rc = ll_close_inode_openhandle(inode, och, MDS_HSM_RELEASE,
+ &data_version);
och = NULL;
EXIT;
mutex_lock(&child_inode->i_mutex);
op_data->op_fid3 = *ll_inode2fid(child_inode);
if (!fid_is_sane(&op_data->op_fid3)) {
- CERROR("%s: migrate %s , but fid "DFID" is insane\n",
+ CERROR("%s: migrate %s, but FID "DFID" is insane\n",
ll_get_fsname(parent->i_sb, NULL, 0), name,
PFID(&op_data->op_fid3));
- GOTO(out_free, rc = -EINVAL);
+ GOTO(out_unlock, rc = -EINVAL);
}
rc = ll_get_mdt_idx_by_fid(ll_i2sbi(parent), &op_data->op_fid3);
if (rc < 0)
- GOTO(out_free, rc);
+ GOTO(out_unlock, rc);
if (rc == mdtidx) {
- CDEBUG(D_INFO, "%s:"DFID" is already on MDT%d.\n", name,
+ CDEBUG(D_INFO, "%s: "DFID" is already on MDT%04x\n", name,
PFID(&op_data->op_fid3), mdtidx);
- GOTO(out_free, rc = 0);
+ GOTO(out_unlock, rc = 0);
}
again:
if (S_ISREG(child_inode->i_mode)) {
if (IS_ERR(och)) {
rc = PTR_ERR(och);
och = NULL;
- GOTO(out_free, rc);
+ GOTO(out_unlock, rc);
}
rc = ll_data_version(child_inode, &data_version,
LL_DV_WR_FLUSH);
if (rc != 0)
- GOTO(out_free, rc);
+ GOTO(out_close, rc);
op_data->op_handle = och->och_fh;
op_data->op_data = och->och_mod;
if (rc == 0)
ll_update_times(request, parent);
- body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY);
- if (body == NULL)
- GOTO(out_free, rc = -EPROTO);
-
- /* If the server does release layout lock, then we cleanup
- * the client och here, otherwise release it in out_free: */
- if (och != NULL && body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) {
- obd_mod_put(och->och_mod);
- md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp, och);
- och->och_fh.cookie = DEAD_HANDLE_MAGIC;
- OBD_FREE_PTR(och);
- och = NULL;
+ if (request != NULL) {
+ body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY);
+ if (body == NULL) {
+ ptlrpc_req_finished(request);
+ GOTO(out_close, rc = -EPROTO);
+ }
+
+ /* If the server does release layout lock, then we cleanup
+ * the client och here, otherwise release it in out_close: */
+ if (och != NULL &&
+ body->mbo_valid & OBD_MD_CLOSE_INTENT_EXECED) {
+ obd_mod_put(och->och_mod);
+ md_clear_open_replay_data(ll_i2sbi(parent)->ll_md_exp,
+ och);
+ och->och_fh.cookie = DEAD_HANDLE_MAGIC;
+ OBD_FREE_PTR(och);
+ och = NULL;
+ }
+ ptlrpc_req_finished(request);
}
- ptlrpc_req_finished(request);
/* Try again if the file layout has changed. */
- if (rc == -EAGAIN && S_ISREG(child_inode->i_mode))
+ if (rc == -EAGAIN && S_ISREG(child_inode->i_mode)) {
+ request = NULL;
goto again;
-out_free:
- if (child_inode != NULL) {
- if (och != NULL) /* close the file */
- ll_lease_close(och, child_inode, NULL);
- clear_nlink(child_inode);
- mutex_unlock(&child_inode->i_mutex);
- iput(child_inode);
}
-
+out_close:
+ if (och != NULL) /* close the file */
+ ll_lease_close(och, child_inode, NULL);
+ if (rc == 0)
+ clear_nlink(child_inode);
+out_unlock:
+ mutex_unlock(&child_inode->i_mutex);
+ iput(child_inode);
+out_free:
ll_finish_md_op_data(op_data);
RETURN(rc);
}