From: Miklos Szeredi <mszeredi@suse.cz>
Use d_splice_alias() instead of d_add() in fuse lookup code, to allow
NFS exporting.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/fuse/dir.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
Index: linux-2.6/fs/fuse/dir.c
===================================================================
--- linux-2.6.orig/fs/fuse/dir.c 2008-05-09 14:04:16.000000000 +0200
+++ linux-2.6/fs/fuse/dir.c 2008-05-09 14:04:49.000000000 +0200
@@ -239,18 +239,20 @@ int fuse_valid_type(int m)
* Add a directory inode to a dentry, ensuring that no other dentry
* refers to this inode. Called with fc->inst_mutex.
*/
-static int fuse_d_add_directory(struct dentry *entry, struct inode *inode)
+static struct dentry *fuse_d_add_directory(struct dentry *entry,
+ struct inode *inode)
{
struct dentry *alias = d_find_alias(inode);
- if (alias) {
+ if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) {
/* This tries to shrink the subtree below alias */
fuse_invalidate_entry(alias);
dput(alias);
if (!list_empty(&inode->i_dentry))
- return -EBUSY;
+ return ERR_PTR(-EBUSY);
+ } else {
+ dput(alias);
}
- d_add(entry, inode);
- return 0;
+ return d_splice_alias(inode, entry);
}
static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
@@ -259,6 +261,7 @@ static struct dentry *fuse_lookup(struct
int err;
struct fuse_entry_out outarg;
struct inode *inode = NULL;
+ struct dentry *newent;
struct fuse_conn *fc = get_fuse_conn(dir);
struct fuse_req *req;
struct fuse_req *forget_req;
@@ -303,21 +306,22 @@ static struct dentry *fuse_lookup(struct
if (inode && S_ISDIR(inode->i_mode)) {
mutex_lock(&fc->inst_mutex);
- err = fuse_d_add_directory(entry, inode);
+ newent = fuse_d_add_directory(entry, inode);
mutex_unlock(&fc->inst_mutex);
- if (err) {
+ if (IS_ERR(newent)) {
iput(inode);
- return ERR_PTR(err);
+ return newent;
}
} else
- d_add(entry, inode);
+ newent = d_splice_alias(inode, entry);
+ entry = newent ? newent : entry;
entry->d_op = &fuse_dentry_operations;
if (!err)
fuse_change_entry_timeout(entry, &outarg);
else
fuse_invalidate_entry_cache(entry);
- return NULL;
+ return newent;
}
/*
--
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| David Miller | [GIT]: Networking |
| Fred . | Please add ZFS support (from GPL sources) |
| Pavel Roskin | [PATCH 2.6.25] module: allow ndiswrapper to use GPL-only symbols |
| David Howells | [PATCH 02/52] CRED: Give in_group_p() a cred pointer |
git: | |
| Dmitry Torokhov | Garbage in .git directories??? |
| Dan Farina | backup or mirror a repository |
| Sergei Organov | Newbie: report of first experience with git-rebase. |
| Richard Quirk | git-cherry-pick no longer detecting moved files in 1.5.3.4 |
| Kevin | uvm_mapent_alloc: out of static map entries on 4.3 i386 |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Douglas A. Tutty | how get colour mutt when ssh from OBSD? |
| Brandon Lee | DELL PERC 5iR slow performance |
| Hubert Feyrer | Compressed vnd handling tested successfully |
| Jaromir Dolecek | Arch-specific maxproc limit? |
| YAMAMOTO Takashi | scheduler_wait_hook |
| David Laight | Re: Integrating securelevel and kauth(9) |
