md_free_lustre_md(sbi->ll_md_exp, &lmd);
ptlrpc_req_finished(request);
- if (root == NULL || IS_ERR(root)) {
- if (lmd.lsm)
- obd_free_memmd(sbi->ll_dt_exp, &lmd.lsm);
+ if (IS_ERR(root)) {
+ if (lmd.lsm)
+ obd_free_memmd(sbi->ll_dt_exp, &lmd.lsm);
#ifdef CONFIG_FS_POSIX_ACL
if (lmd.posix_acl) {
posix_acl_release(lmd.posix_acl);
lsm_md2->lsm_md_pool_name) == 0;
}
-static void ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
+static int ll_update_lsm_md(struct inode *inode, struct lustre_md *md)
{
struct ll_inode_info *lli = ll_i2info(inode);
struct lmv_stripe_md *lsm = md->lmv;
- int idx;
+ int idx;
+ int rc;
ENTRY;
LASSERT(S_ISDIR(inode->i_mode));
/* no striped information from request. */
if (lsm == NULL) {
if (lli->lli_lsm_md == NULL) {
- RETURN_EXIT;
+ RETURN(0);
} else if (lli->lli_lsm_md->lsm_md_magic == LMV_MAGIC_MIGRATE) {
/* migration is done, the temporay MIGRATE layout has
* been removed */
PFID(ll_inode2fid(inode)));
lmv_free_memmd(lli->lli_lsm_md);
lli->lli_lsm_md = NULL;
- RETURN_EXIT;
+ RETURN(0);
} else {
/* The lustre_md from req does not include stripeEA,
* see ll_md_setattr */
- RETURN_EXIT;
+ RETURN(0);
}
}
/* set the directory layout */
if (lli->lli_lsm_md == NULL) {
- int rc;
rc = ll_init_lsm_md(inode, md);
- if (rc != 0) {
- CERROR("%s: init "DFID" failed: rc = %d\n",
- ll_get_fsname(inode->i_sb, NULL, 0),
- PFID(&lli->lli_fid), rc);
- return;
- }
+ if (rc != 0)
+ RETURN(rc);
+
lli->lli_lsm_md = lsm;
/* set lsm_md to NULL, so the following free lustre_md
* will not free this lsm */
md->lmv = NULL;
CDEBUG(D_INODE, "Set lsm %p magic %x to "DFID"\n", lsm,
lsm->lsm_md_magic, PFID(ll_inode2fid(inode)));
- RETURN_EXIT;
+ RETURN(0);
}
/* Compare the old and new stripe information */
lli->lli_lsm_md->lsm_md_layout_version,
lsm->lsm_md_pool_name,
lli->lli_lsm_md->lsm_md_pool_name);
- return;
+ RETURN(-EIO);
}
for (idx = 0; idx < lli->lli_lsm_md->lsm_md_stripe_count; idx++) {
ll_get_fsname(inode->i_sb, NULL, 0), idx,
PFID(&lli->lli_lsm_md->lsm_md_oinfo[idx].lmo_fid),
PFID(&lsm->lsm_md_oinfo[idx].lmo_fid));
- return;
+ RETURN(-EIO);
}
}
- md_update_lsm_md(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
- md->body, ll_md_blocking_ast);
+ rc = md_update_lsm_md(ll_i2mdexp(inode), ll_i2info(inode)->lli_lsm_md,
+ md->body, ll_md_blocking_ast);
- RETURN_EXIT;
+ RETURN(rc);
}
void ll_clear_inode(struct inode *inode)
ll_clear_inode_capas(inode);
if (S_ISDIR(inode->i_mode))
ll_dir_clear_lsm_md(inode);
- else
+ else if (S_ISREG(inode->i_mode) && !is_bad_inode(inode))
LASSERT(list_empty(&lli->lli_agl_list));
/*
op_data->op_handle = md.body->handle;
op_data->op_ioepoch = md.body->ioepoch;
- ll_update_inode(inode, &md);
- ptlrpc_req_finished(request);
+ rc = ll_update_inode(inode, &md);
+ ptlrpc_req_finished(request);
- RETURN(rc);
+ RETURN(rc);
}
/* Close IO epoch and send Size-on-MDS attribute update. */
mutex_unlock(&lli->lli_size_mutex);
}
-void ll_update_inode(struct inode *inode, struct lustre_md *md)
+int ll_update_inode(struct inode *inode, struct lustre_md *md)
{
struct ll_inode_info *lli = ll_i2info(inode);
struct mdt_body *body = md->body;
lli->lli_maxbytes = MAX_LFS_FILESIZE;
}
- if (S_ISDIR(inode->i_mode))
- ll_update_lsm_md(inode, md);
+ if (S_ISDIR(inode->i_mode)) {
+ int rc;
+
+ rc = ll_update_lsm_md(inode, md);
+ if (rc != 0)
+ return rc;
+ }
if (sbi->ll_flags & LL_SBI_RMT_CLIENT) {
if (body->valid & OBD_MD_FLRMTPERM)
if (body->t_state & MS_RESTORE)
lli->lli_flags |= LLIF_FILE_RESTORING;
}
+
+ return 0;
}
-void ll_read_inode2(struct inode *inode, void *opaque)
+int ll_read_inode2(struct inode *inode, void *opaque)
{
struct lustre_md *md = opaque;
struct ll_inode_info *lli = ll_i2info(inode);
+ int rc;
ENTRY;
CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n",
LTIME_S(inode->i_atime) = 0;
LTIME_S(inode->i_ctime) = 0;
inode->i_rdev = 0;
- ll_update_inode(inode, md);
+ rc = ll_update_inode(inode, md);
+ if (rc != 0)
+ RETURN(rc);
/* OIDEBUG(inode); */
EXIT;
}
+
+ return 0;
}
void ll_delete_inode(struct inode *inode)
if (rc)
RETURN(rc);
- if (*inode) {
- ll_update_inode(*inode, &md);
- } else {
- LASSERT(sb != NULL);
+ if (*inode) {
+ rc = ll_update_inode(*inode, &md);
+ if (rc != 0)
+ GOTO(out, rc);
+ } else {
+ LASSERT(sb != NULL);
/*
* At this point server returns to client's same fid as client
*inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1,
sbi->ll_flags & LL_SBI_32BIT_API),
&md);
- if (*inode == NULL || IS_ERR(*inode)) {
+ if (IS_ERR(*inode)) {
#ifdef CONFIG_FS_POSIX_ACL
if (md.posix_acl) {
posix_acl_release(md.posix_acl);
}
-/*
- * Get an inode by inode number (already instantiated by the intent lookup).
- * Returns inode or NULL
+/**
+ * Get an inode by inode number(@hash), which is already instantiated by
+ * the intent lookup).
*/
struct inode *ll_iget(struct super_block *sb, ino_t hash,
struct lustre_md *md)
{
- struct inode *inode;
- ENTRY;
+ struct inode *inode;
+ int rc = 0;
+
+ ENTRY;
LASSERT(hash != 0);
inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
+ if (inode == NULL)
+ RETURN(ERR_PTR(-ENOMEM));
+
+ if (inode->i_state & I_NEW) {
+ rc = ll_read_inode2(inode, md);
+ if (rc == 0 && S_ISREG(inode->i_mode) &&
+ ll_i2info(inode)->lli_clob == NULL) {
+ CDEBUG(D_INODE, "%s: apply lsm %p to inode "DFID"\n",
+ ll_get_fsname(sb, NULL, 0), md->lsm,
+ PFID(ll_inode2fid(inode)));
+ rc = cl_file_inode_init(inode, md);
+ }
+ if (rc != 0) {
+ make_bad_inode(inode);
+ unlock_new_inode(inode);
+ iput(inode);
+ inode = ERR_PTR(rc);
+ } else {
+ unlock_new_inode(inode);
+ }
+ } else if (!(inode->i_state & (I_FREEING | I_CLEAR))) {
+ rc = ll_update_inode(inode, md);
+ CDEBUG(D_VFSTRACE, "got inode: "DFID"(%p): rc = %d\n",
+ PFID(&md->body->fid1), inode, rc);
+ if (rc != 0) {
+ make_bad_inode(inode);
+ iput(inode);
+ inode = ERR_PTR(rc);
+ }
+ }
- if (inode) {
- if (inode->i_state & I_NEW) {
- int rc = 0;
-
- ll_read_inode2(inode, md);
- if (S_ISREG(inode->i_mode) &&
- ll_i2info(inode)->lli_clob == NULL) {
- CDEBUG(D_INODE,
- "%s: apply lsm %p to inode "DFID".\n",
- ll_get_fsname(sb, NULL, 0), md->lsm,
- PFID(ll_inode2fid(inode)));
- rc = cl_file_inode_init(inode, md);
- }
- if (rc != 0) {
- make_bad_inode(inode);
- unlock_new_inode(inode);
- iput(inode);
- inode = ERR_PTR(rc);
- } else
- unlock_new_inode(inode);
- } else if (!(inode->i_state & (I_FREEING | I_CLEAR)))
- ll_update_inode(inode, md);
- CDEBUG(D_VFSTRACE, "got inode: "DFID"(%p)\n",
- PFID(&md->body->fid1), inode);
- }
RETURN(inode);
}