X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fllite%2Fllite_nfs.c;h=7f3f56bd88ba8c778ba5638f3ea2d49aa598ad73;hb=a80cacd8184639aaddd615437f3ff976e9b91b62;hp=ffb8a0769e27c6cc2c96210c062510333efc857a;hpb=96a5daa0c08d7b42ec368080a2a7f0dfb110ef98;p=fs%2Flustre-release.git diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index ffb8a07..7f3f56b 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -28,6 +28,9 @@ /* * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011 Whamcloud, Inc. + * */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -114,8 +117,13 @@ static struct inode *search_inode_for_lustre(struct super_block *sb, RETURN(inode); } -static struct dentry *ll_iget_for_nfs(struct super_block *sb, - const struct lu_fid *fid) +struct lustre_nfs_fid { + struct lu_fid lnf_child; + struct lu_fid lnf_parent; +}; + +static struct dentry * +ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *parent) { struct inode *inode; struct dentry *result; @@ -131,15 +139,26 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb, if (is_bad_inode(inode)) { /* we didn't find the right inode.. */ - CERROR("can't get inode by fid "DFID"\n", - PFID(fid)); iput(inode); 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_smd == NULL && + parent != NULL) { + struct ll_inode_info *lli = ll_i2info(inode); + + cfs_spin_lock(&lli->lli_lock); + lli->lli_pfid = *parent; + cfs_spin_unlock(&lli->lli_lock); + } + result = d_obtain_alias(inode); - if (!result) - RETURN(ERR_PTR(-ENOMEM)); + if (IS_ERR(result)) + RETURN(result); ll_dops_init(result, 1, 0); @@ -148,11 +167,6 @@ static struct dentry *ll_iget_for_nfs(struct super_block *sb, #define LUSTRE_NFS_FID 0x97 -struct lustre_nfs_fid { - struct lu_fid lnf_child; - struct lu_fid lnf_parent; -}; - /** * \a connectable - is nfsd will connect himself or this should be done * at lustre @@ -217,7 +231,8 @@ static int ll_get_name(struct dentry *dentry, char *name, if (!dir->i_fop) GOTO(out, rc = -EINVAL); - filp = ll_dentry_open(dget(dentry), NULL, O_RDONLY, current_cred()); + filp = ll_dentry_open(dget(dentry), mntget(ll_i2sbi(dir)->ll_mnt), + O_RDONLY, current_cred()); if (IS_ERR(filp)) GOTO(out, rc = PTR_ERR(filp)); @@ -250,7 +265,7 @@ static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, if (fh_type != LUSTRE_NFS_FID) RETURN(ERR_PTR(-EPROTO)); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child)); + RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent)); } static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, @@ -261,7 +276,7 @@ static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, if (fh_type != LUSTRE_NFS_FID) RETURN(ERR_PTR(-EPROTO)); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent)); + RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL)); } #else @@ -293,11 +308,10 @@ static struct dentry *ll_decode_fh(struct super_block *sb, __u32 *fh, int fh_len static struct dentry *ll_get_dentry(struct super_block *sb, void *data) { - struct lustre_nfs_fid *fid = data; - struct dentry *entry; + struct dentry *entry; ENTRY; - entry = ll_iget_for_nfs(sb, &fid->lnf_child); + entry = ll_iget_for_nfs(sb, data, NULL); RETURN(entry); } #endif @@ -338,7 +352,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild) 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); + result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL); ptlrpc_req_finished(req); RETURN(result);