Whamcloud - gitweb
LU-3544 fid: do open-by-fid by default
[fs/lustre-release.git] / lustre / llite / llite_nfs.c
index d92424f..bc56fbf 100644 (file)
@@ -136,12 +136,18 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
                 RETURN(ERR_PTR(-ESTALE));
         }
 
-        /**
-         * It is an anonymous dentry without OST objects created yet.
-         * We have to find the parent to tell MDS how to init lov objects.
-         */
-       if (S_ISREG(inode->i_mode) && !ll_i2info(inode)->lli_has_smd &&
-           parent != NULL && !fid_is_zero(parent)) {
+       result = d_obtain_alias(inode);
+       if (IS_ERR(result)) {
+               iput(inode);
+               RETURN(result);
+       }
+
+       /**
+        * In case d_obtain_alias() found a disconnected dentry, always update
+        * lli_pfid to allow later operation (normally open) have parent fid,
+        * which may be used by MDS to create data.
+        */
+       if (parent != NULL) {
                struct ll_inode_info *lli = ll_i2info(inode);
 
                spin_lock(&lli->lli_lock);
@@ -149,12 +155,6 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren
                spin_unlock(&lli->lli_lock);
        }
 
-       result = d_obtain_alias(inode);
-       if (IS_ERR(result)) {
-               iput(inode);
-               RETURN(result);
-       }
-
         RETURN(result);
 }
 
@@ -239,6 +239,7 @@ static int ll_get_name(struct dentry *dentry, char *name,
                .lgd_found = 0,
        };
        struct md_op_data *op_data;
+       __u64   pos = 0;
        int rc;
        ENTRY;
 
@@ -253,13 +254,12 @@ static int ll_get_name(struct dentry *dentry, char *name,
        if (IS_ERR(op_data))
                GOTO(out, rc = PTR_ERR(op_data));
 
-       op_data->op_hash_offset = 0;
        op_data->op_max_pages = ll_i2sbi(dir)->ll_md_brw_pages;
        mutex_lock(&dir->i_mutex);
 #ifdef HAVE_DIR_CONTEXT
-       rc = ll_dir_read(dir, op_data, &lgd.ctx);
+       rc = ll_dir_read(dir, &pos, op_data, &lgd.ctx);
 #else
-       rc = ll_dir_read(dir, op_data, &lgd, ll_nfs_get_name_filldir);
+       rc = ll_dir_read(dir, &pos, op_data, &lgd, ll_nfs_get_name_filldir);
 #endif
        mutex_unlock(&dir->i_mutex);
        ll_finish_md_op_data(op_data);