All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: Allow nfsd over cifs
@ 2011-02-28 21:52 shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
       [not found] ` <1298929961-5541-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 21+ messages in thread
From: shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w @ 2011-02-28 21:52 UTC (permalink / raw)
  To: smfrench-Re5JQEeQqe8AvxtiuMwx3w
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	bfields-uC3wQj2KruNg9hUCZPvPmw, Shirish Pargaonkar

From: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


Define structure cifs_fid to span 64 bits of inode ids.
Allow nfsd over cifs.
Add export ops encode_fh and fh_to_dentry.
Add a function to find inodes off of a superblock, using only id.


Signed-off-by: Shirish Pargaonkar <shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 fs/cifs/cifsfs.c    |    4 +-
 fs/cifs/cifsfs.h    |    4 +-
 fs/cifs/cifsglob.h  |    5 ++++
 fs/cifs/cifsproto.h |    2 +
 fs/cifs/dir.c       |   16 +++++--------
 fs/cifs/export.c    |   58 +++++++++++++++++++++++++++++++++++++-------------
 fs/cifs/inode.c     |   15 ++++++++++++-
 7 files changed, 74 insertions(+), 30 deletions(-)

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 13b3999..29ff05c 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -187,12 +187,12 @@ cifs_read_super(struct super_block *sb, void *data,
 	else
 		sb->s_d_op = &cifs_dentry_ops;
 
-#ifdef CIFS_NFSD_EXPORT
+#ifdef CONFIG_CIFS_NFSD_EXPORT
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
 		cFYI(1, "export ops supported");
 		sb->s_export_op = &cifs_export_ops;
 	}
-#endif /* CIFS_NFSD_EXPORT */
+#endif /* CONFIG_CIFS_NFSD_EXPORT */
 
 	return 0;
 
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index 371d021..1d8185d 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -123,9 +123,9 @@ extern ssize_t	cifs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t	cifs_listxattr(struct dentry *, char *, size_t);
 extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
 
-#ifdef CIFS_NFSD_EXPORT
+#ifdef CONFIG_CIFS_NFSD_EXPORT
 extern const struct export_operations cifs_export_ops;
-#endif /* CIFS_NFSD_EXPORT */
+#endif /* CONFIG_CIFS_NFSD_EXPORT */
 
 #define CIFS_VERSION   "1.71"
 #endif				/* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index e1098c3..c7faac6 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -672,6 +672,11 @@ static inline void free_dfs_info_array(struct dfs_info3_param *param,
 	kfree(param);
 }
 
+struct cifs_fid {
+	u64 cino;
+	u64 cpino;
+};
+
 #define   MID_FREE 0
 #define   MID_REQUEST_ALLOCATED 1
 #define   MID_REQUEST_SUBMITTED 2
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index da7a492..0d0afd2 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -432,6 +432,8 @@ extern int mdfour(unsigned char *, unsigned char *, int);
 extern int E_md4hash(const unsigned char *passwd, unsigned char *p16);
 extern void SMBencrypt(unsigned char *passwd, const unsigned char *c8,
 			unsigned char *p24);
+extern int cifs_find_inode_id(struct inode *, void *);
+extern int cifs_init_inode(struct inode *, void *);
 extern void E_P16(unsigned char *p14, unsigned char *p16);
 extern void E_P24(unsigned char *p21, const unsigned char *c8,
 			unsigned char *p24);
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index dd5f229..4e9c38f 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -491,6 +491,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 	struct inode *newInode = NULL;
 	char *full_path = NULL;
 	struct file *filp;
+	struct dentry *spdirentry = NULL;
 
 	xid = GetXid();
 
@@ -586,7 +587,9 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
 				parent_dir_inode->i_sb, xid, NULL);
 
 	if ((rc == 0) && (newInode != NULL)) {
-		d_add(direntry, newInode);
+		spdirentry = d_splice_alias(newInode, direntry);
+		if (spdirentry)
+			return spdirentry;
 		if (posix_open) {
 			filp = lookup_instantiate_filp(nd, direntry,
 						       generic_file_open);
@@ -631,7 +634,7 @@ lookup_out:
 static int
 cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
 {
-	if (nd->flags & LOOKUP_RCU)
+	if (nd && nd->flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	if (direntry->d_inode) {
@@ -642,18 +645,11 @@ cifs_d_revalidate(struct dentry *direntry, struct nameidata *nd)
 	}
 
 	/*
-	 * This may be nfsd (or something), anyway, we can't see the
-	 * intent of this. So, since this can be for creation, drop it.
-	 */
-	if (!nd)
-		return 0;
-
-	/*
 	 * Drop the negative dentry, in order to make sure to use the
 	 * case sensitive name which is specified by user if this is
 	 * for creation.
 	 */
-	if (!(nd->flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))) {
+	if (nd && !(nd->flags & (LOOKUP_CONTINUE | LOOKUP_PARENT))) {
 		if (nd->flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
 			return 0;
 	}
diff --git a/fs/cifs/export.c b/fs/cifs/export.c
index 55d87ac..fd8397f 100644
--- a/fs/cifs/export.c
+++ b/fs/cifs/export.c
@@ -44,24 +44,52 @@
 #include "cifsglob.h"
 #include "cifs_debug.h"
 #include "cifsfs.h"
+#include "cifsproto.h"
 
-#ifdef CIFS_NFSD_EXPORT
-static struct dentry *cifs_get_parent(struct dentry *dentry)
+#ifdef CONFIG_CIFS_NFSD_EXPORT
+static int cifs_encode_fh(struct dentry *dentry, __u32 *fh, int *lenp,
+				int connectable)
 {
-	/* BB need to add code here eventually to enable export via NFSD */
-	cFYI(1, "get parent for %p", dentry);
-	return ERR_PTR(-EACCES);
+	struct cifs_fid *cfid = (struct cifs_fid *)fh;
+	struct inode *inode = dentry->d_inode;
+
+	cfid->cino = inode->i_ino;
+
+	/*
+	 * There is not a type to send ino32_gen32_parentino32_gen32 to
+	 * accomodate two 64 bit inode numbers. So always return this type.
+	 */
+	return FILEID_INO32_GEN;
 }
 
-const struct export_operations cifs_export_ops = {
-	.get_parent = cifs_get_parent,
-/*	Following five export operations are unneeded so far and can default:
-	.get_dentry =
-	.get_name =
-	.find_exported_dentry =
-	.decode_fh =
-	.encode_fs =  */
-};
+static struct dentry *
+cifs_fh_to_dentry(struct super_block *sb, struct fid *fh,
+			int fh_len, int fh_type)
+{
+	struct cifs_fid *cfid = (struct cifs_fid *)fh;
+	struct inode *inode = NULL;
+	struct cifs_fattr fattr;
+
 
-#endif /* CIFS_NFSD_EXPORT */
+	if (fh_type != FILEID_INO32_GEN && fh_type != FILEID_INO32_GEN_PARENT) {
+		cERROR(1, "%s: Can't handle fh type: %d", __func__, fh_type);
+		return ERR_PTR(-EINVAL);
+	}
 
+	if (!cfid->cino)
+		return ERR_PTR(-ESTALE);
+
+	fattr.cf_uniqueid = cfid->cino;
+	inode = iget5_locked(sb, cfid->cino, cifs_find_inode_id,
+					cifs_init_inode, &fattr);
+	if (IS_ERR(inode))
+		return ERR_CAST(inode);
+
+	return d_obtain_alias(inode);
+}
+
+const struct export_operations cifs_export_ops = {
+	.encode_fh = cifs_encode_fh,
+	.fh_to_dentry = cifs_fh_to_dentry
+};
+#endif /* CONFIG_CIFS_NFSD_EXPORT */
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 196ef60..9c86535 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -777,6 +777,19 @@ char *cifs_build_path_to_root(struct cifs_sb_info *cifs_sb,
 	return full_path;
 }
 
+int
+cifs_find_inode_id(struct inode *inode, void *opaque)
+{
+	int rc = 0;
+	struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
+
+	/* match inode with uniqueid */
+	if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid)
+		rc = 1;
+
+	return rc;
+}
+
 static int
 cifs_find_inode(struct inode *inode, void *opaque)
 {
@@ -801,7 +814,7 @@ cifs_find_inode(struct inode *inode, void *opaque)
 	return 1;
 }
 
-static int
+int
 cifs_init_inode(struct inode *inode, void *opaque)
 {
 	struct cifs_fattr *fattr = (struct cifs_fattr *) opaque;
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2011-03-23 17:57 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-28 21:52 [PATCH] cifs: Allow nfsd over cifs shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w
     [not found] ` <1298929961-5541-1-git-send-email-shirishpargaonkar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-02-28 22:49   ` J. Bruce Fields
     [not found]     ` <20110228224957.GB14237-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-02-28 22:58       ` Steve French
     [not found]         ` <AANLkTimDd-m388VJTC1zJtf3Q7LkFcsvNuwcY6vRwt7K-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-28 23:42           ` J. Bruce Fields
     [not found]             ` <20110228234225.GC14237-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-02-28 23:52               ` Steve French
     [not found]                 ` <AANLkTikeSEYOs_nzno40eM0ZSrStMqcziPzWGRViT5M--JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-28 23:59                   ` J. Bruce Fields
     [not found]                     ` <20110228235910.GD14237-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-01  2:33                       ` Steve French
     [not found]                         ` <AANLkTinFwcBMmPpn0_30Bjaa+0ipoJ6qrM=u1TGQ+Q8g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-01  3:28                           ` J. Bruce Fields
     [not found]                             ` <20110301032808.GA17725-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-01 18:07                               ` J. Bruce Fields
     [not found]                                 ` <20110301180700.GC20599-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-01 18:30                                   ` Shirish Pargaonkar
     [not found]                                     ` <AANLkTikNH0ujA-qram1=1JEqJ7DH6dLRR723YZgJde1+-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-01 19:21                                       ` J. Bruce Fields
     [not found]                                         ` <20110301192102.GD20599-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-01 20:09                                           ` Jeff Layton
     [not found]                                             ` <20110301150949.6ca5b880-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-03-01 20:11                                               ` Steve French
     [not found]                                                 ` <AANLkTikc2GAe1+jRyuJGEJ8i5EBtoO-dayocL2yATMWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-01 20:31                                                   ` Jeff Layton
     [not found]                                                     ` <20110301153111.6673e191-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2011-03-01 20:37                                                       ` Steve French
2011-03-01 20:34                                                   ` J. Bruce Fields
     [not found]                                                     ` <20110301203445.GE20599-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-01 20:38                                                       ` Steve French
     [not found]                                                         ` <AANLkTikaGd6EzNBWkYrJM3upP4fnBUx4p7c_29cLReLX-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-01 20:48                                                           ` J. Bruce Fields
     [not found]                                                             ` <20110301204807.GF20599-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-03-16 15:30                                                               ` Jeff Layton
     [not found]                                                                 ` <4D80DAA5.6030106@likewise.com>
     [not found]                                                                   ` <AANLkTik9hN2jVW6+=LnwY1xaCLqGBW6-BeG-=dmZgCnr@mail.gmail.com>
     [not found]                                                                     ` <AANLkTikA6akj7GDM_H7ndbMvPc6rnRtZ_i_zEHMrG31H@mail.gmail.com>
     [not found]                                                                       ` <AANLkTinbOJRmrudrCyQ9zHTSUr69RV-1NTyoc1NOFAjz@mail.gmail.com>
     [not found]                                                                         ` <AANLkTincOKZ5YjN9cKYaTByu7DST7bzQvO5XESsStTDh@mail.gmail.com>
     [not found]                                                                           ` <AANLkTi=2EpL2F=+t0eDuGv_OrkxtgNxxu02_iv+ashbU@mail.gmail.com>
     [not found]                                                                             ` <AANLkTimLAg74dVMZqOrZ60CYe_94Q1ihwWGq7DaDTVyG@mail.gmail.com>
     [not found]                                                                               ` <AANLkTin+NAGqF5EJjVJZ1tW62tQcjmJLP8njfGLqsFZQ@mail.gmail.com>
     [not found]                                                                                 ` <AANLkTinUiU47-621kVwignvL0Dud1nTYc1RhnHMKQQz2@mail.gmail.com>
     [not found]                                                                                   ` <AANLkTi=St7RiwyEy0Fq-P16cfSTEvN0-BEgWC4NOsujx@mail.gmail.com>
     [not found]                                                                                     ` <AANLkTik5HcN=Lz70fGD1wN6GkZkQy4BWa7Ovz4RNghA0@mail.gmail.com>
     [not found]                                                                                       ` <AANLkTimYByiDRRjwrcNM+HKK6t_hgoS_oWn3hXVbzkF+@mail.gmail.com>
     [not found]                                                                                         ` <AANLkTi=0aG4iOtJPxe2zZnx9hW2DUGGArnR6s_jioZ=E@mail.gmail.com>
     [not found]                                                                                           ` <AANLkTimsD73JRzhFTycYKZBcgL9q3VjA1Dpj8judwWFE@mail.gmail.com>
     [not found]                                                                                             ` <AANLkTikcSyXoqbBKG+0iyX1zN=TfYQ5dTH9BTSoLg-42@mail.gmail.com>
     [not found]                                                                                               ` <AANLkTikcSyXoqbBKG+0iyX1zN=TfYQ5dTH9BTSoLg-42-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-03-23 17:57                                                                                                 ` Steve French
2011-03-01  5:17   ` Shirish Pargaonkar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.