summaryrefslogtreecommitdiff
path: root/drivers/staging/lustre/lustre/llite/namei.c
diff options
context:
space:
mode:
authorwang di <di.wang@intel.com>2016-08-16 16:18:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-21 15:57:36 +0200
commitc3397e7e677b1186f0442293de415f1c070b9d5d (patch)
treeebdd3024cddc21f68f1d138178227f6ca0815b8b /drivers/staging/lustre/lustre/llite/namei.c
parent8877d3bff10ab1d02794c43013be7e68b83ce7ea (diff)
staging: lustre: llite: add error handler in inode prepare phase
Add error handler during inode inialization, so inode will become bad inode if something bad happens during inode prepare phase, otherwise the striped directory will not get its layout and being mis-regarded as normal directory. Signed-off-by: wang di <di.wang@intel.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4930 Reviewed-on: http://review.whamcloud.com/10170 Reviewed-by: Lai Siyao <lai.siyao@intel.com> Reviewed-by: Fan Yong <fan.yong@intel.com> Reviewed-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lustre/llite/namei.c')
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index f05988248d9b..6e11b9961aa0 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -96,41 +96,46 @@ static int ll_set_inode(struct inode *inode, void *opaque)
return 0;
}
-/*
- * 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;
+ int rc = 0;
LASSERT(hash != 0);
inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
-
- 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) {
- 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) {
- iget_failed(inode);
- inode = NULL;
- } 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);
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+
+ if (inode->i_state & I_NEW) {
+ rc = ll_read_inode2(inode, md);
+ if (!rc && S_ISREG(inode->i_mode) &&
+ !ll_i2info(inode)->lli_clob) {
+ 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) {
+ 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) {
+ make_bad_inode(inode);
+ iput(inode);
+ inode = ERR_PTR(rc);
}
}
return inode;