Whamcloud - gitweb
LU-3952 nfs: don't panic NFS server if MDS fails to find FID
[fs/lustre-release.git] / lustre / llite / llite_nfs.c
index 2926caf..2a2eb19 100644 (file)
@@ -127,8 +127,8 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
         struct dentry *result;
         ENTRY;
 
-        if (!fid_is_sane(fid))
-                RETURN(ERR_PTR(-ESTALE));
+       if (!fid_is_sane(fid))
+               RETURN(ERR_PTR(-ESTALE));
 
        CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid));
 
@@ -311,28 +311,31 @@ static struct dentry *ll_get_parent(struct dentry *dchild)
 
        op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot,
                                     strlen(dotdot), lmmsize,
-                                     LUSTRE_OPC_ANY, NULL);
-        if (IS_ERR(op_data))
-                RETURN((void *)op_data);
+                                    LUSTRE_OPC_ANY, NULL);
+       if (IS_ERR(op_data))
+               RETURN((void *)op_data);
 
-        rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
-        ll_finish_md_op_data(op_data);
-        if (rc) {
+       rc = md_getattr_name(sbi->ll_md_exp, op_data, &req);
+       ll_finish_md_op_data(op_data);
+       if (rc) {
                CERROR("%s: failure inode "DFID" get parent: rc = %d\n",
                       ll_get_fsname(dir->i_sb, NULL, 0),
                       PFID(ll_inode2fid(dir)), rc);
-                RETURN(ERR_PTR(rc));
-        }
-        body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
-        LASSERT(body->valid & OBD_MD_FLID);
-
-        CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n",
-                PFID(ll_inode2fid(dir)), PFID(&body->fid1));
-
-        result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL);
+               RETURN(ERR_PTR(rc));
+       }
+       body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
+       /*
+        * LU-3952: MDT may lost the FID of its parent, we should not crash
+        * the NFS server, ll_iget_for_nfs() will handle the error.
+        */
+       if (body->valid & OBD_MD_FLID) {
+               CDEBUG(D_INFO, "parent for "DFID" is "DFID"\n",
+                      PFID(ll_inode2fid(dir)), PFID(&body->fid1));
+       }
+       result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL);
 
-        ptlrpc_req_finished(req);
-        RETURN(result);
+       ptlrpc_req_finished(req);
+       RETURN(result);
 }
 
 struct export_operations lustre_export_operations = {