Skip to contentSkip to conversation

pnfsd-exofs: New set of exofs pnfs export patches

PATCH In review Boaz Harrosh 3 participants 22 messages Jun 14, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover pnfsd-exofs: New set of exofs pnfs export patches

Benny hi

I'm submitting a new SQUASHED set of exofs patches. These should completely replace the patches you have now in the pnfsd-exofs{-all} branch

If anyone is curios I'll send a SQUASHME patchset as reply to this mail.

I Think the pnfsd-exofs branch should advance down to before the pnfsd-exp-all. It should be the first or second candidate for inclusion.

BTW: You forgot to branch the pnfs-blocks branch last time.

I think that now, since most of the client code is in-tree and all the common code is in. It would be easier to work with a tree that has two separate branches for the 1.block-layout and 2.server branches. And the pnfs-all-latest which merges the two.

something like:

                |----pnfsd(including gfs2_---pnfsd-exofs---pnfsd-exp----pnfsd-spnfs----pnfsd-spnfs-blocks ---|
nfs-linux-next--|                                                                                            + --- pnfs-all-latest
                | --------pnfs-blocks------------------------------------------------------------------------|

* "+" means a merge

It will be much easier to develop this way

usual list of patches:

[PATCH 1/8] nfs_xdr: Move nfs4_string definition out of #ifdef CONFIG_NFS_V4 [PATCH 2/8] exofs: pnfs-tree: Remove pnfs-osd private definitions [PATCH 3/8] pnfs-obj: pnfs_osd_xdr: Remove dead code and cleanup

Intended for upstream

[PATCH 4/8] pnfsd-exofs: pnfs objects server XDR functions [PATCH 5/8] pnfsd-exofs: Add pNFS export support
[PATCH 6/8] pnfsd-exofs: get_device_info implementation. [PATCH 7/8] pnfsd-exofs: Recall layouts on truncate [PATCH 8/8] pnfsd-exofs: layoutreturn pnfs-obj information decoding

New exofs pnfs export patches

Thanks
Boaz

#1 lore raw
Quoted 6 lines · Boaz Harrosh

Benny hi

I'm submitting a new SQUASHED set of exofs patches. These should completely replace the patches you have now in the pnfsd-exofs{-all} branch

Great, thanks!

Quoted 4 lines

If anyone is curios I'll send a SQUASHME patchset as reply to this mail.

I Think the pnfsd-exofs branch should advance down to before the pnfsd-exp-all. It should be the first or second candidate for inclusion.

makes sense

Quoted 2 lines

BTW: You forgot to branch the pnfs-blocks branch last time.

Already fixed... (pnfs-block is there)

Quoted 11 lines

I think that now, since most of the client code is in-tree and all the common code is in. It would be easier to work with a tree that has two separate branches for the 1.block-layout and 2.server branches. And the pnfs-all-latest which merges the two.

something like:

                |----pnfsd(including gfs2_---pnfsd-exofs---pnfsd-exp----pnfsd-spnfs----pnfsd-spnfs-blocks ---|
nfs-linux-next--|                                                                                            + --- pnfs-all-latest
                | --------pnfs-blocks------------------------------------------------------------------------|

Good point, I'll try it out.

Quoted 13 lines

* "+" means a merge

It will be much easier to develop this way

usual list of patches:

[PATCH 1/8] nfs_xdr: Move nfs4_string definition out of #ifdef CONFIG_NFS_V4 [PATCH 2/8] exofs: pnfs-tree: Remove pnfs-osd private definitions [PATCH 3/8] pnfs-obj: pnfs_osd_xdr: Remove dead code and cleanup

Intended for upstream

Quoted 7 lines

[PATCH 4/8] pnfsd-exofs: pnfs objects server XDR functions [PATCH 5/8] pnfsd-exofs: Add pNFS export support
[PATCH 6/8] pnfsd-exofs: get_device_info implementation. [PATCH 7/8] pnfsd-exofs: Recall layouts on truncate [PATCH 8/8] pnfsd-exofs: layoutreturn pnfs-obj information decoding

New exofs pnfs export patches

Where are the patches? :)

Benny

Quoted 9 lines

Thanks
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

OK, I took this in under pnfs-all-3.0-rc3-2011-06-14-2 The new tree structure is:

master (at nfs-2.6/nfs-for-bakeathon, based off of v3.0-rc3)

	nfs-upstream
		pnfs-block
			pnfs-obj
	nfsd-upstream
		nfsd41-all
			pnfsd-all
				pnfsd-exofs-all
					pnfsd-lexp-all
						spnfs-all
							spnfs-block-all
								pnfs-all-latest
								+pnfs-obj (that's a merge :)

Benny

Quoted 70 lines · Benny Halevy
Quoted 6 lines · Boaz Harrosh

Benny hi

I'm submitting a new SQUASHED set of exofs patches. These should completely replace the patches you have now in the pnfsd-exofs{-all} branch

Great, thanks!

Quoted 4 lines

If anyone is curios I'll send a SQUASHME patchset as reply to this mail.

I Think the pnfsd-exofs branch should advance down to before the pnfsd-exp-all. It should be the first or second candidate for inclusion.

makes sense

Quoted 2 lines

BTW: You forgot to branch the pnfs-blocks branch last time.

Already fixed... (pnfs-block is there)

Quoted 11 lines

I think that now, since most of the client code is in-tree and all the common code is in. It would be easier to work with a tree that has two separate branches for the 1.block-layout and 2.server branches. And the pnfs-all-latest which merges the two.

something like:

                |----pnfsd(including gfs2_---pnfsd-exofs---pnfsd-exp----pnfsd-spnfs----pnfsd-spnfs-blocks ---|
nfs-linux-next--|                                                                                            + --- pnfs-all-latest
                | --------pnfs-blocks------------------------------------------------------------------------|

Good point, I'll try it out.

Quoted 13 lines

* "+" means a merge

It will be much easier to develop this way

usual list of patches:

[PATCH 1/8] nfs_xdr: Move nfs4_string definition out of #ifdef CONFIG_NFS_V4 [PATCH 2/8] exofs: pnfs-tree: Remove pnfs-osd private definitions [PATCH 3/8] pnfs-obj: pnfs_osd_xdr: Remove dead code and cleanup

Intended for upstream

Quoted 7 lines

[PATCH 4/8] pnfsd-exofs: pnfs objects server XDR functions [PATCH 5/8] pnfsd-exofs: Add pNFS export support
[PATCH 6/8] pnfsd-exofs: get_device_info implementation. [PATCH 7/8] pnfsd-exofs: Recall layouts on truncate [PATCH 8/8] pnfsd-exofs: layoutreturn pnfs-obj information decoding

New exofs pnfs export patches

Where are the patches? :)

Benny

Quoted 9 lines

Thanks
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 1/8 nfs_xdr: Move nfs4_string definition out of #ifdef CONFIG_NFS_V4

In reply to Boaz Harrosh

exofs file system wants to use pnfs_osd_xdr.h file instead of redefining pnfs-objects types in it's private "pnfs.h" headr.

Before we do the switch we must make sure pnfs_osd_xdr.h is compilable also under NFS versions smaller than 4.1. Since now it is needed regardless of version, by the exofs code.

nfs4_string is not the only nfs4 type out in the global scope.

---
 include/linux/nfs_xdr.h |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
include/linux/nfs_xdr.h +5 -5
index 0a21844..7372921 100644
@@ -774,6 +774,11 @@ struct nfs3_getaclres {
 	struct posix_acl *	acl_default;
 };
 
+struct nfs4_string {
+	unsigned int len;
+	char *data;
+};
+
 #ifdef CONFIG_NFS_V4
 
 typedef u64 clientid4;
@@ -964,11 +969,6 @@ struct nfs4_server_caps_res {
 	struct nfs4_sequence_res	seq_res;
 };
 
-struct nfs4_string {
-	unsigned int len;
-	char *data;
-};
-
 #define NFS4_PATHNAME_MAXCOMPONENTS 512
 struct nfs4_pathname {
 	unsigned int ncomponents;
Signature · 1 line
1.7.3.4
#4 lore raw

PATCH 2/8 exofs: pnfs-tree: Remove pnfs-osd private definitions

In reply to Boaz Harrosh

Now that pnfs-osd has hit mainline we can remove exofs's private header. (And the FIXME comment)

---
 fs/exofs/exofs.h |    6 +-----
 fs/exofs/pnfs.h  |   45 ---------------------------------------------
 2 files changed, 1 insertions(+), 50 deletions(-)
 delete mode 100644 fs/exofs/pnfs.h
fs/exofs/exofs.h +1 -5
index c965806..e103dbd 100644
@@ -36,13 +36,9 @@
 #include <linux/fs.h>
 #include <linux/time.h>
 #include <linux/backing-dev.h>
+#include <linux/pnfs_osd_xdr.h>
 #include "common.h"
 
-/* FIXME: Remove once pnfs hits mainline
- * #include <linux/exportfs/pnfs_osd_xdr.h>
- */
-#include "pnfs.h"
-
 #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a)
 
 #ifdef CONFIG_EXOFS_DEBUG
fs/exofs/pnfs.h deleted +0 -45

45 lines not on this page · raw message

Signature · 1 line
1.7.3.4
#5 lore raw

PATCH 3/8 pnfs-obj: pnfs_osd_xdr: Remove dead code and cleanup

In reply to Boaz Harrosh

From: Boaz Harrosh <Boaz Harrosh [email protected]>

* Some leftovers from ancient times.
* This file will only define common types and client API. Remove server from comments

Signed-off-by Boaz Harrosh <Boaz Harrosh [email protected]>
---
 include/linux/pnfs_osd_xdr.h |   31 ++-----------------------------
 1 files changed, 2 insertions(+), 29 deletions(-)
include/linux/pnfs_osd_xdr.h +2 -29
index 76efbdd..435dd5f 100644
@@ -41,9 +41,6 @@
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_page.h>
-#include <scsi/osd_protocol.h>
-
-#define PNFS_OSD_OSDNAME_MAXSIZE 256
 
 /*
  * draft-ietf-nfsv4-minorversion-22
@@ -99,12 +96,6 @@ struct pnfs_osd_objid {
 #define _DEVID_HI(oid_device_id) \
 	(unsigned long long)be64_to_cpup(((__be64 *)(oid_device_id)->data) + 1)
 
-static inline int
-pnfs_osd_objid_xdr_sz(void)
-{
-	return (NFS4_DEVICEID4_SIZE / 4) + 2 + 2;
-}
-
 enum pnfs_osd_version {
 	PNFS_OSD_MISSING              = 0,
 	PNFS_OSD_VERSION_1            = 1,
@@ -189,8 +180,6 @@ struct pnfs_osd_targetid {
 	struct nfs4_string		oti_scsi_device_id;
 };
 
-enum { PNFS_OSD_TARGETID_MAX = 1 + PNFS_OSD_OSDNAME_MAXSIZE / 4 };
-
 /*   struct netaddr4 {
  *       // see struct rpcb in RFC1833
  *       string r_netid<>;    // network id
@@ -207,12 +196,6 @@ struct pnfs_osd_targetaddr {
 	struct pnfs_osd_net_addr	ota_netaddr;
 };
 
-enum {
-	NETWORK_ID_MAX = 16 / 4,
-	UNIVERSAL_ADDRESS_MAX = 64 / 4,
-	PNFS_OSD_TARGETADDR_MAX = 3 +  NETWORK_ID_MAX + UNIVERSAL_ADDRESS_MAX,
-};
-
 struct pnfs_osd_deviceaddr {
 	struct pnfs_osd_targetid	oda_targetid;
 	struct pnfs_osd_targetaddr	oda_targetaddr;
@@ -222,15 +205,6 @@ struct pnfs_osd_deviceaddr {
 	struct nfs4_string		oda_osdname;
 };
 
-enum {
-	ODA_OSDNAME_MAX = PNFS_OSD_OSDNAME_MAXSIZE / 4,
-	PNFS_OSD_DEVICEADDR_MAX =
-		PNFS_OSD_TARGETID_MAX + PNFS_OSD_TARGETADDR_MAX +
-		2 /*oda_lun*/ +
-		1 + OSD_SYSTEMID_LEN +
-		1 + ODA_OSDNAME_MAX,
-};
-
 /* LAYOUTCOMMIT: layoutupdate */
 
 /*   union pnfs_osd_deltaspaceused4 switch (bool dsu_valid) {
@@ -279,7 +253,7 @@ struct pnfs_osd_ioerr {
 	u32			oer_errno;
 };
 
-/* OSD XDR API */
+/* OSD XDR Client API */
 /* Layout helpers */
 /* Layout decoding is done in two parts:
  * 1. First Call pnfs_osd_xdr_decode_layout_map to read in only the header part
@@ -337,8 +311,7 @@ extern int
 pnfs_osd_xdr_encode_layoutupdate(struct xdr_stream *xdr,
 				 struct pnfs_osd_layoutupdate *lou);
 
-/* osd_ioerror encoding/decoding (layout_return) */
-/* Client */
+/* osd_ioerror encoding (layout_return) */
 extern __be32 *pnfs_osd_xdr_ioerr_reserve_space(struct xdr_stream *xdr);
 extern void pnfs_osd_xdr_encode_ioerr(__be32 *p, struct pnfs_osd_ioerr *ioerr);
 
Signature · 1 line
1.7.3.4
#6 lore raw

PATCH 4/8 pnfsd-exofs: pnfs objects server XDR functions

In reply to Boaz Harrosh

* Server support for encoding a pnfs_osd_layout4 XDR stream.

* Implementation of pnfs_osd_xdr_encode_deviceaddr(). Which takes a pnfs_osd_deviceaddr structure and encodes it onto an XDR stream.

* Implementation of pnfs_osd_xdr_decode_ioerr() used by servers in layout_return notifications.

* Implementation of pnfs_osd_xdr_decode_layoutupdate() used by servers in layout_commit notifications.

* Add pnfs_osd_xdr_srv.c to fs/exportfs/Makefile conditional on CONFIG_EXPORTFS_OSD_LAYOUT selected

* Add CONFIG_EXPORTFS_OSD_LAYOUT to fs/Kconfig. It is prompt-less needs to be selected by osd filesystems

TODO: We can now remove the olo_comps pointer from
struct pnfs_osd_layout neither the server nor client use it any more. (rename it to pnfs_osd_layout_hdr)

Signed-off-by Boaz Harrosh <Boaz Harrosh [email protected]>
---
 fs/Kconfig                            |    8 +
 fs/exportfs/Makefile                  |    1 +
 fs/exportfs/pnfs_osd_xdr_srv.c        |  287 +++++++++++++++++++++++++++++++++
 include/linux/nfsd/pnfs_osd_xdr_srv.h |   40 +++++
 4 files changed, 336 insertions(+), 0 deletions(-)
 create mode 100644 fs/exportfs/pnfs_osd_xdr_srv.c
 create mode 100644 include/linux/nfsd/pnfs_osd_xdr_srv.h
fs/Kconfig +8 -0
index 320670e..4980006 100644
@@ -56,6 +56,14 @@ config EXPORTFS_FILE_LAYOUT
 	  Exportfs support for the NFSv4.1 files layout type.
 	  Must be automatically selected by supporting filesystems.
 
+config EXPORTFS_OSD_LAYOUT
+	bool
+	depends on PNFSD && EXPORTFS
+	help
+	  Exportfs support for the NFSv4.1 objects layout type.
+	  Must be automatically selected by supporting osd
+	  filesystems.
+
 config FILE_LOCKING
 	bool "Enable POSIX file locking API" if EXPERT
 	default y
fs/exportfs/Makefile +1 -0
index 658207d..f6ea13f 100644
@@ -5,3 +5,4 @@ obj-$(CONFIG_EXPORTFS) += exportfs.o
 
 exportfs-y				:= expfs.o
 exportfs-$(CONFIG_EXPORTFS_FILE_LAYOUT)	+= nfs4filelayoutxdr.o
+exportfs-$(CONFIG_EXPORTFS_OSD_LAYOUT)	+= pnfs_osd_xdr_srv.o
fs/exportfs/pnfs_osd_xdr_srv.c new file +287 -0

287 lines not on this page · raw message

include/linux/nfsd/pnfs_osd_xdr_srv.h new file +40 -0
new file mode 100644
index 0000000..fab244e
@@ -0,0 +1,40 @@
+/*
+ * pnfs-objects Server XDR definitions and API
+ *
+ * Copyright (C) from 2011 Panasas Inc.  All rights reserved.
+ *
+ * Authors:
+ *   Boaz Harrosh <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ *
+ */
+#ifndef __PNFS_OSD_XDR_SRV_H__
+#define __PNFS_OSD_XDR_SRV_H__
+
+#include <linux/pnfs_osd_xdr.h>
+#include <linux/exp_xdr.h>
+
+/* Layout encoding */
+enum nfsstat4 pnfs_osd_xdr_encode_layout_hdr(
+	struct exp_xdr_stream *xdr,
+	struct pnfs_osd_layout *layout);
+
+enum nfsstat4 pnfs_osd_xdr_encode_layout_cred(
+	struct exp_xdr_stream *xdr,
+	struct pnfs_osd_object_cred *cred);
+
+/* deviceaddr encoding */
+enum nfsstat4 pnfs_osd_xdr_encode_deviceaddr(
+	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
+
+/* layout_commit decoding */
+__be32 *pnfs_osd_xdr_decode_layoutupdate(
+	struct pnfs_osd_layoutupdate *lou, __be32 *p);
+
+/* layout_return decoding */
+bool pnfs_osd_xdr_decode_ioerr(
+	struct pnfs_osd_ioerr *ioerr, struct exp_xdr_stream *xdr);
+
+#endif /* __PNFS_OSD_XDR_SRV_H__ */
Signature · 1 line
1.7.3.4
#7 lore raw

PATCH 5/8 pnfsd-exofs: Add pNFS export support

In reply to Boaz Harrosh

Add a new file export.c that implements the pnfs_export_operations. And set a pointer to it in the super_block.

Implemented: LAYOUTGET, simple LAYOUTCOMMIT, simple LAYOUTRETURN

missing: GETDEVICEINFO, Recalls. These will come in next patches

export.c inclusion is dependent on CONFIG_PNFSD defined. If not then the few used functions from export.c are defined empty in exofs.h.

In that case of PNFSD EXPORTFS_OSD_LAYOUT must be selected in fs/exofs/Kconfig

---
 fs/exofs/Kbuild   |    1 +
 fs/exofs/Kconfig  |    1 +
 fs/exofs/exofs.h  |    7 ++
 fs/exofs/export.c |  198 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/exofs/super.c  |    1 +
 5 files changed, 208 insertions(+), 0 deletions(-)
 create mode 100644 fs/exofs/export.c
fs/exofs/Kbuild +1 -0
index 2d0f757..5458546 100644
@@ -13,4 +13,5 @@
 #
 
 exofs-y := ios.o inode.o file.o symlink.o namei.o dir.o super.o
+exofs-$(CONFIG_PNFSD) +=  export.o
 obj-$(CONFIG_EXOFS_FS) += exofs.o
fs/exofs/Kconfig +1 -0
index 86194b2..77c677f 100644
@@ -1,6 +1,7 @@
 config EXOFS_FS
 	tristate "exofs: OSD based file system support"
 	depends on SCSI_OSD_ULD
+	select EXPORTFS_OSD_LAYOUT if PNFSD
 	help
 	  EXOFS is a file system that uses an OSD storage device,
 	  as its backing storage.
fs/exofs/exofs.h +7 -0
index e103dbd..3469d77 100644
@@ -301,4 +301,11 @@ extern const struct inode_operations exofs_special_inode_operations;
 extern const struct inode_operations exofs_symlink_inode_operations;
 extern const struct inode_operations exofs_fast_symlink_inode_operations;
 
+/* export.c */
+#ifdef CONFIG_PNFSD
+void exofs_init_export(struct super_block *sb);
+#else
+static inline void exofs_init_export(struct super_block *sb) {}
+#endif
+
 #endif
fs/exofs/export.c new file +198 -0

198 lines not on this page · raw message

fs/exofs/super.c +1 -0
index 06065bd..96ecb15 100644
@@ -770,6 +770,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
 	sb->s_fs_info = sbi;
 	sb->s_op = &exofs_sops;
 	sb->s_export_op = &exofs_export_ops;
+	exofs_init_export(sb);
 	root = exofs_iget(sb, EXOFS_ROOT_ID - EXOFS_OBJ_OFF);
 	if (IS_ERR(root)) {
 		EXOFS_ERR("ERROR: exofs_iget failed\n");
Signature · 1 line
1.7.3.4
#8 lore raw

PATCH 6/8 pnfsd-exofs: get_device_info implementation.

In reply to Boaz Harrosh

Implement a .get_device_info operation from the
pnfs_export_operations.

Retrieve to system_id and osdname for the requested devices.

TODO: Return also UNC hints for the device login
information.

---
 fs/exofs/export.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
fs/exofs/export.c +54 -0
index 0a068b7..23c1666 100644
@@ -185,11 +185,65 @@ static int exofs_layout_return(
 	return 0;
 }
 
+int exofs_get_device_info(struct super_block *sb, struct exp_xdr_stream *xdr,
+			  u32 layout_type,
+			  const struct nfsd4_pnfs_deviceid *devid)
+{
+	struct exofs_sb_info *sbi = sb->s_fs_info;
+	struct pnfs_osd_deviceaddr devaddr;
+	const struct osd_dev_info *odi;
+	u64 devno = devid->devid;
+	__be32 *start;
+	int err;
+
+	memset(&devaddr, 0, sizeof(devaddr));
+
+	if (unlikely(devno >= sbi->layout.s_numdevs)) {
+		EXOFS_DBGMSG("Error: Device((%llx,%llx) does not exist\n",
+			     devid->sbid, devno);
+		return -ENODEV;
+	}
+
+	odi = osduld_device_info(sbi->layout.s_ods[devno]);
+
+	devaddr.oda_systemid.len = odi->systemid_len;
+	devaddr.oda_systemid.data = (void *)odi->systemid; /* !const cast */
+
+	devaddr.oda_osdname.len = odi->osdname_len ;
+	devaddr.oda_osdname.data = (void *)odi->osdname;/* !const cast */
+
+	/* skip opaque size, will be filled-in later */
+	start = exp_xdr_reserve_qwords(xdr, 1);
+	if (!start) {
+		err = -ETOOSMALL;
+		goto err;
+	}
+
+	err = pnfs_osd_xdr_encode_deviceaddr(xdr, &devaddr);
+	if (err) {
+		err = -ETOOSMALL;
+		goto err;
+	}
+
+	exp_xdr_encode_opaque_len(start, xdr->p);
+
+	EXOFS_DBGMSG("xdr_bytes=%Zu devid=(%llx,%llx) osdname-%s\n",
+		     exp_xdr_qbytes(xdr->p - start), devid->sbid, devno,
+		     odi->osdname);
+	return 0;
+
+err:
+	EXOFS_DBGMSG("Error: err=%d at_byte=%zu\n",
+		     err, exp_xdr_qbytes(xdr->p - start));
+	return err;
+}
+
 struct pnfs_export_operations exofs_pnfs_ops = {
 	.layout_type	= exofs_layout_type,
 	.layout_get	= exofs_layout_get,
 	.layout_commit	= exofs_layout_commit,
 	.layout_return	= exofs_layout_return,
+	.get_device_info = exofs_get_device_info,
 };
 
 void exofs_init_export(struct super_block *sb)
Signature · 1 line
1.7.3.4
#9 lore raw

PATCH 7/8 pnfsd-exofs: Recall layouts on truncate

In reply to Boaz Harrosh

From: Boaz Harrosh <Boaz Harrosh [email protected]>

* Define a new exofs_inode_recall_layout() which receives a function pointer. The function pointer is called when all layouts have returned, and before any new will be given.

* At exofs_layout_return() when all layouts recalled have returned, above exofs_inode_recall_layout() is awaken.

* At exofs_truncate() recall all layouts on the file.

[added u64 todo_data param starting 2.6.36]
[pnfsd-exofs: Fix exofs_inode_recall_layout() sending 2 recalls]

A misunderstanding of the wait_event_interruptible() macro has caused exofs to always issue two recalls in succession.

Using __wait_event_interruptible() would fix that. But I don't like how this code is structured so change it around completely to be more flat and clear.

---
 fs/exofs/exofs.h  |   14 ++++++
 fs/exofs/export.c |  131 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 fs/exofs/inode.c  |    7 ++-
 3 files changed, 147 insertions(+), 5 deletions(-)
fs/exofs/exofs.h +14 -0
index 3469d77..45c9fe5 100644
@@ -99,6 +99,7 @@ struct exofs_sb_info {
 struct exofs_i_info {
 	struct inode   vfs_inode;          /* normal in-memory inode          */
 	wait_queue_head_t i_wq;            /* wait queue for inode            */
+	spinlock_t     i_layout_lock;      /* lock for layout/return/recall   */
 	unsigned long  i_flags;            /* various atomic flags            */
 	uint32_t       i_data[EXOFS_IDATA];/*short symlink names and device #s*/
 	uint32_t       i_dir_start_lookup; /* which page to start lookup      */
@@ -162,6 +163,9 @@ static inline unsigned exofs_io_state_size(unsigned numdevs)
  */
 #define OBJ_2BCREATED	0	/* object will be created soon*/
 #define OBJ_CREATED	1	/* object has been created on the osd*/
+/* Below are not used atomic but reuse the same i_flags */
+#define OBJ_LAYOUT_IS_GIVEN  2  /* inode has given layouts to clients*/
+#define OBJ_IN_LAYOUT_RECALL 3  /* inode is in the middle of a layout recall*/
 
 static inline int obj_2bcreated(struct exofs_i_info *oi)
 {
@@ -302,9 +306,19 @@ extern const struct inode_operations exofs_symlink_inode_operations;
 extern const struct inode_operations exofs_fast_symlink_inode_operations;
 
 /* export.c */
+typedef int (exofs_recall_fn)(struct inode *inode, u64 data);
 #ifdef CONFIG_PNFSD
+int exofs_inode_recall_layout(struct inode *inode, enum pnfs_iomode iomode,
+			      exofs_recall_fn todo, u64 todo_data);
 void exofs_init_export(struct super_block *sb);
 #else
+static inline int
+exofs_inode_recall_layout(struct inode *inode, enum pnfs_iomode iomode,
+exofs_recall_fn todo, u64 todo_data)
+{
+	return todo(inode, todo_data);
+}
+
 static inline void exofs_init_export(struct super_block *sb) {}
 #endif
 
fs/exofs/export.c +128 -3

169 lines not on this page · raw message

fs/exofs/inode.c +5 -2
index 8472c09..1365e72 100644
@@ -847,8 +847,9 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode)
 const struct osd_attr g_attr_logical_length = ATTR_DEF(
 	OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
 
-static int _do_truncate(struct inode *inode, loff_t newsize)
+static int _do_truncate(struct inode *inode, u64 data)
 {
+	loff_t newsize = data;
 	struct exofs_i_info *oi = exofs_i(inode);
 	int ret;
 
@@ -885,7 +886,8 @@ int exofs_setattr(struct dentry *dentry, struct iattr *iattr)
 
 	if ((iattr->ia_valid & ATTR_SIZE) &&
 	    iattr->ia_size != i_size_read(inode)) {
-		error = _do_truncate(inode, iattr->ia_size);
+		error = exofs_inode_recall_layout(inode, IOMODE_ANY,
+						  _do_truncate, iattr->ia_size);
 		if (unlikely(error))
 			return error;
 	}
@@ -998,6 +1000,7 @@ static void __oi_init(struct exofs_i_info *oi)
 {
 	init_waitqueue_head(&oi->i_wq);
 	oi->i_flags = 0;
+	spin_lock_init(&oi->i_layout_lock);
 }
 /*
  * Fill in an inode read from the OSD and set it up for use
Signature · 1 line
1.7.3.4
#10 lore raw

PATCH 8/8 pnfsd-exofs: layoutreturn pnfs-obj information decoding

In reply to Boaz Harrosh

Use pnfs_osd_xdr_decode_ioerr() in exofs_layout_return, and print the received errors.

TODO: Call exofs_file_recovery() on errors that need it.
(When it's implemented)

---
 fs/exofs/export.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
fs/exofs/export.c +21 -1
index c0705df..8281c85 100644
@@ -229,11 +229,31 @@ static int exofs_layout_commit(
 	return 0;
 }
 
+static void exofs_handle_error(struct pnfs_osd_ioerr *ioerr)
+{
+	EXOFS_ERR("exofs_handle_error: errno=%d is_write=%d obj=0x%llx "
+		  "offset=0x%llx length=0x%llx\n",
+		  ioerr->oer_errno, ioerr->oer_iswrite,
+		  _LLU(ioerr->oer_component.oid_object_id),
+		  _LLU(ioerr->oer_comp_offset),
+		  _LLU(ioerr->oer_comp_length));
+}
+
 static int exofs_layout_return(
 	struct inode *inode,
 	const struct nfsd4_pnfs_layoutreturn_arg *args)
 {
-	/* TODO: Decode the pnfs_osd_ioerr if lrf_body_len > 0 */
+	struct exp_xdr_stream xdr = {
+		.p = args->lrf_body,
+		.end = args->lrf_body + exp_xdr_qwords(args->lrf_body_len),
+	};
+	struct pnfs_osd_ioerr ioerr;
+
+	EXOFS_DBGMSG("(0x%lx) cookie %p body_len %d\n",
+		     inode->i_ino, args->lr_cookie, args->lrf_body_len);
+
+	while (pnfs_osd_xdr_decode_ioerr(&ioerr, &xdr))
+		exofs_handle_error(&ioerr);
 
 	if (args->lr_cookie) {
 		struct exofs_i_info *oi = exofs_i(inode);
Signature · 1 line
1.7.3.4
#11 lore raw

cover pnfsd-exofs: SQUASHMES that went into last changes

In reply to Boaz Harrosh

here are the list of changes done to the old tree

[PATCH 01/10] SQUASHME: pnfsd-exofs xdr_srv: Wrong type in comments
[PATCH 02/10] SQUASHME: pnfsd-exofs: Move all Server xdr definisions to separate header [PATCH 03/10] SQUASHME: pnfsd-exofs: Prettify pnfs_osd_xdr_srv.h
[PATCH 04/10] SQUASHME: pnfsd-exofs: Change layout encoding to two pass [PATCH 05/10] SQUASHME: pnfsd-exofs: osd_xdr_srv: Convert XDR API to return enum nfsstat4 [PATCH 06/10] SQUASHME: pnfsd-exofs: Server xdr definisions were moved to a separate header [PATCH 07/10] SQUASHME: pnfsd-exofs: osd_xdr_srv header moved
[PATCH 08/10] SQUASHME: pnfsd-exofs: layout encoding was Changed to two pass [PATCH 09/10] SQUASHME: pnfsd-exofs: Convert XDR API to return enum nfsstat4 [PATCH 09/10] SQUASHME: pnfsd-exofs: checkpatch love and a dprint

Boaz

#12 lore raw

PATCH 1/10 SQUASHME: pnfsd-exofs xdr_srv: Wrong type in comments

Boaz

---
 fs/exportfs/pnfs_osd_xdr_srv.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/exportfs/pnfs_osd_xdr_srv.c +2 -2
index fc7d805..444798c 100644
@@ -71,7 +71,7 @@ static int pnfs_osd_xdr_encode_data_map(
 
 /*
  * struct pnfs_osd_objid {
- * 	struct pnfs_deviceid	oid_device_id;
+ * 	struct nfs4_deviceid	oid_device_id;
  * 	u64			oid_partition_id;
  * 	u64			oid_object_id;
  * };
@@ -249,7 +249,7 @@ EXPORT_SYMBOL(pnfs_osd_xdr_decode_layoutupdate);
 
 /*
  * struct pnfs_osd_objid {
- * 	struct pnfs_deviceid	oid_device_id;
+ * 	struct nfs4_deviceid	oid_device_id;
  * 	u64			oid_partition_id;
  * 	u64			oid_object_id;
  * }; xdr size 32
Signature · 1 line
1.7.3.4
#13 lore raw

PATCH 2/10 SQUASHME: pnfsd-exofs: Move all Server xdr definisions to separate header

In reply to Boaz Harrosh

Server XDR definitions are defined in there own header

---
 fs/exportfs/pnfs_osd_xdr_srv.c        |    3 ++-
 include/linux/nfsd/pnfs_osd_xdr_srv.h |   17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletions(-)
 create mode 100644 include/linux/nfsd/pnfs_osd_xdr_srv.h
fs/exportfs/pnfs_osd_xdr_srv.c +2 -1
index 444798c..67564f6 100644
@@ -38,7 +38,8 @@
  */
 
 #include <linux/nfsd/nfsd4_pnfs.h>
-#include <linux/pnfs_osd_xdr.h>
+
+#include "linux/nfsd/pnfs_osd_xdr_srv.h"
 
 /*
  * struct pnfs_osd_data_map {
include/linux/nfsd/pnfs_osd_xdr_srv.h new file +17 -0
new file mode 100644
index 0000000..65de588
@@ -0,0 +1,17 @@
+#include <linux/pnfs_osd_xdr.h>
+#include <linux/exp_xdr.h>
+
+/* Layout encoding */
+extern int pnfs_osd_xdr_encode_layout(
+	struct exp_xdr_stream *xdr,
+	struct pnfs_osd_layout *layout);
+
+/* deviceaddr for Servers */
+extern int pnfs_osd_xdr_encode_deviceaddr(
+	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
+
+extern __be32 * pnfs_osd_xdr_decode_layoutupdate(
+	struct pnfs_osd_layoutupdate *lou, __be32 *p);
+
+extern bool pnfs_osd_xdr_decode_ioerr(
+	struct pnfs_osd_ioerr *ioerr, struct exp_xdr_stream *xdr);
Signature · 1 line
1.7.3.4
#14 lore raw

PATCH 3/10 SQUASHME: pnfsd-exofs: Prettify pnfs_osd_xdr_srv.h

In reply to Boaz Harrosh
---
 include/linux/nfsd/pnfs_osd_xdr_srv.h |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)
include/linux/nfsd/pnfs_osd_xdr_srv.h +24 -5
index 65de588..256a7e07 100644
@@ -1,17 +1,36 @@
+/*
+ * pnfs-objects Server XDR definitions and API
+ *
+ * Copyright (C) from 2011 Panasas Inc.  All rights reserved.
+ *
+ * Authors:
+ *   Boaz Harrosh <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ *
+ */
+#ifndef __PNFS_OSD_XDR_SRV_H__
+#define __PNFS_OSD_XDR_SRV_H__
+
 #include <linux/pnfs_osd_xdr.h>
 #include <linux/exp_xdr.h>
 
 /* Layout encoding */
-extern int pnfs_osd_xdr_encode_layout(
+int pnfs_osd_xdr_encode_layout(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_layout *layout);
 
-/* deviceaddr for Servers */
-extern int pnfs_osd_xdr_encode_deviceaddr(
+/* deviceaddr encoding */
+int pnfs_osd_xdr_encode_deviceaddr(
 	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
 
-extern __be32 * pnfs_osd_xdr_decode_layoutupdate(
+/* layout_commit decoding */
+__be32 * pnfs_osd_xdr_decode_layoutupdate(
 	struct pnfs_osd_layoutupdate *lou, __be32 *p);
 
-extern bool pnfs_osd_xdr_decode_ioerr(
+/* layout_return decoding */
+bool pnfs_osd_xdr_decode_ioerr(
 	struct pnfs_osd_ioerr *ioerr, struct exp_xdr_stream *xdr);
+
+#endif /* __PNFS_OSD_XDR_SRV_H__ */
Signature · 1 line
1.7.3.4
#15 lore raw

PATCH 4/10 SQUASHME: pnfsd-exofs: Change layout encoding to two pass

In reply to Boaz Harrosh

This way there is No need for dynamic allocation of the creds array.

TODO: We can now remove the olo_comps pointer from
struct pnfs_osd_layout neither the server nor client use it any more. (rename it to pnfs_osd_layout_hdr)

---
 fs/exportfs/pnfs_osd_xdr_srv.c        |   16 +++++-----------
 include/linux/nfsd/pnfs_osd_xdr_srv.h |    6 +++++-
 2 files changed, 10 insertions(+), 12 deletions(-)
fs/exportfs/pnfs_osd_xdr_srv.c +5 -11
index 67564f6..ec814c1 100644
@@ -110,7 +110,7 @@ static inline int pnfs_osd_xdr_encode_objid(
  * 	struct pnfs_osd_opaque_cred	oc_cap;
  * };
  */
-static int pnfs_osd_xdr_encode_object_cred(
+int pnfs_osd_xdr_encode_layout_cred(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_object_cred *olo_comp)
 {
@@ -136,6 +136,7 @@ static int pnfs_osd_xdr_encode_object_cred(
 
 	return 0;
 }
+EXPORT_SYMBOL(pnfs_osd_xdr_encode_layout_cred);
 
 /*
  * struct pnfs_osd_layout {
@@ -145,12 +146,11 @@ static int pnfs_osd_xdr_encode_object_cred(
  * 	struct pnfs_osd_object_cred	*olo_comps;
  * };
  */
-int pnfs_osd_xdr_encode_layout(
+int pnfs_osd_xdr_encode_layout_hdr(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_layout *pol)
 {
 	__be32 *p;
-	u32 i;
 	int err;
 
 	err = pnfs_osd_xdr_encode_data_map(xdr, &pol->olo_map);
@@ -164,15 +164,9 @@ int pnfs_osd_xdr_encode_layout(
 	p = exp_xdr_encode_u32(p, pol->olo_comps_index);
 	p = exp_xdr_encode_u32(p, pol->olo_num_comps);
 
-	for (i = 0; i < pol->olo_num_comps; i++) {
-		err = pnfs_osd_xdr_encode_object_cred(xdr, &pol->olo_comps[i]);
-		if (err)
-			return err;
-	}
-
 	return 0;
 }
-EXPORT_SYMBOL(pnfs_osd_xdr_encode_layout);
+EXPORT_SYMBOL(pnfs_osd_xdr_encode_layout_hdr);
 
 static int _encode_string(struct exp_xdr_stream *xdr,
 			  const struct nfs4_string *str)
@@ -217,7 +211,7 @@ int pnfs_osd_xdr_encode_deviceaddr(
 	if (err)
 		return err;
 
-	err = pnfs_osd_xdr_encode_object_cred(xdr,
+	err = pnfs_osd_xdr_encode_layout_cred(xdr,
 					      &devaddr->oda_root_obj_cred);
 	if (err)
 		return err;
include/linux/nfsd/pnfs_osd_xdr_srv.h +5 -1
index 256a7e07..e9a2187 100644
@@ -17,10 +17,14 @@
 #include <linux/exp_xdr.h>
 
 /* Layout encoding */
-int pnfs_osd_xdr_encode_layout(
+int pnfs_osd_xdr_encode_layout_hdr(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_layout *layout);
 
+int pnfs_osd_xdr_encode_layout_cred(
+	struct exp_xdr_stream *xdr,
+	struct pnfs_osd_object_cred *cred);
+
 /* deviceaddr encoding */
 int pnfs_osd_xdr_encode_deviceaddr(
 	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
Signature · 1 line
1.7.3.4
#16 lore raw

PATCH 5/10 SQUASHME: pnfsd-exofs: osd_xdr_srv: Convert XDR API to return enum nfsstat4

In reply to Boaz Harrosh

* Change pnfs_osd_xdr_srv API to return nfs4 errors

---
 fs/exportfs/pnfs_osd_xdr_srv.c        |   30 +++++++++++++++---------------
 include/linux/nfsd/pnfs_osd_xdr_srv.h |    6 +++---
 2 files changed, 18 insertions(+), 18 deletions(-)
fs/exportfs/pnfs_osd_xdr_srv.c +15 -15
index ec814c1..4d92f1c 100644
@@ -51,14 +51,14 @@
  * 	u32	odm_raid_algorithm;
  * };
  */
-static int pnfs_osd_xdr_encode_data_map(
+static enum nfsstat4 pnfs_osd_xdr_encode_data_map(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_data_map *data_map)
 {
 	__be32 *p = exp_xdr_reserve_qwords(xdr, 1+2+1+1+1+1);
 
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 
 	p = exp_xdr_encode_u32(p, data_map->odm_num_comps);
 	p = exp_xdr_encode_u64(p, data_map->odm_stripe_unit);
@@ -77,7 +77,7 @@ static int pnfs_osd_xdr_encode_data_map(
  * 	u64			oid_object_id;
  * };
  */
-static inline int pnfs_osd_xdr_encode_objid(
+static inline enum nfsstat4 pnfs_osd_xdr_encode_objid(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_objid *object_id)
 {
@@ -86,7 +86,7 @@ static inline int pnfs_osd_xdr_encode_objid(
 		(struct nfsd4_pnfs_deviceid *)&object_id->oid_device_id;
 
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 
 	p = exp_xdr_encode_u64(p, dev_id->fsid);
 	p = exp_xdr_encode_u64(p, dev_id->devid);
@@ -110,12 +110,12 @@ static inline int pnfs_osd_xdr_encode_objid(
  * 	struct pnfs_osd_opaque_cred	oc_cap;
  * };
  */
-int pnfs_osd_xdr_encode_layout_cred(
+enum nfsstat4 pnfs_osd_xdr_encode_layout_cred(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_object_cred *olo_comp)
 {
 	__be32 *p;
-	int err;
+	enum nfsstat4 err;
 
 	err = pnfs_osd_xdr_encode_objid(xdr, &olo_comp->oc_object_id);
 	if (err)
@@ -123,7 +123,7 @@ int pnfs_osd_xdr_encode_layout_cred(
 
 	p = exp_xdr_reserve_space(xdr, 3*4 + 4+olo_comp->oc_cap.cred_len);
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 
 	p = exp_xdr_encode_u32(p, olo_comp->oc_osd_version);
 
@@ -146,12 +146,12 @@ EXPORT_SYMBOL(pnfs_osd_xdr_encode_layout_cred);
  * 	struct pnfs_osd_object_cred	*olo_comps;
  * };
  */
-int pnfs_osd_xdr_encode_layout_hdr(
+enum nfsstat4 pnfs_osd_xdr_encode_layout_hdr(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_layout *pol)
 {
 	__be32 *p;
-	int err;
+	enum nfsstat4 err;
 
 	err = pnfs_osd_xdr_encode_data_map(xdr, &pol->olo_map);
 	if (err)
@@ -159,7 +159,7 @@ int pnfs_osd_xdr_encode_layout_hdr(
 
 	p = exp_xdr_reserve_qwords(xdr, 2);
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 
 	p = exp_xdr_encode_u32(p, pol->olo_comps_index);
 	p = exp_xdr_encode_u32(p, pol->olo_num_comps);
@@ -168,13 +168,13 @@ int pnfs_osd_xdr_encode_layout_hdr(
 }
 EXPORT_SYMBOL(pnfs_osd_xdr_encode_layout_hdr);
 
-static int _encode_string(struct exp_xdr_stream *xdr,
+static enum nfsstat4 _encode_string(struct exp_xdr_stream *xdr,
 			  const struct nfs4_string *str)
 {
 	__be32 *p = exp_xdr_reserve_space(xdr, 4 + str->len);
 
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 	exp_xdr_encode_opaque(p, str->data, str->len);
 	return 0;
 }
@@ -188,15 +188,15 @@ static int _encode_string(struct exp_xdr_stream *xdr,
  * 	struct nfs4_string		oda_osdname;
  * };
  */
-int pnfs_osd_xdr_encode_deviceaddr(
+enum nfsstat4 pnfs_osd_xdr_encode_deviceaddr(
 	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr)
 {
 	__be32 *p;
-	int err;
+	enum nfsstat4 err;
 
 	p = exp_xdr_reserve_space(xdr, 4 + 4 + sizeof(devaddr->oda_lun));
 	if (!p)
-		return -E2BIG;
+		return NFS4ERR_TOOSMALL;
 
 	/* Empty oda_targetid */
 	p = exp_xdr_encode_u32(p, OBJ_TARGET_ANON);
include/linux/nfsd/pnfs_osd_xdr_srv.h +3 -3
index e9a2187..2909fbe 100644
@@ -17,16 +17,16 @@
 #include <linux/exp_xdr.h>
 
 /* Layout encoding */
-int pnfs_osd_xdr_encode_layout_hdr(
+enum nfsstat4 pnfs_osd_xdr_encode_layout_hdr(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_layout *layout);
 
-int pnfs_osd_xdr_encode_layout_cred(
+enum nfsstat4 pnfs_osd_xdr_encode_layout_cred(
 	struct exp_xdr_stream *xdr,
 	struct pnfs_osd_object_cred *cred);
 
 /* deviceaddr encoding */
-int pnfs_osd_xdr_encode_deviceaddr(
+enum nfsstat4 pnfs_osd_xdr_encode_deviceaddr(
 	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
 
 /* layout_commit decoding */
Signature · 1 line
1.7.3.4
#17 lore raw

PATCH 6/10 SQUASHME: pnfsd-exofs: Server xdr definisions were moved to a separate header

In reply to Boaz Harrosh

Include from export.c the server XDR header

---
 fs/exofs/export.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/exofs/export.c +2 -0
index c8a7d46..20969bf 100644
@@ -27,6 +27,8 @@
 #include <linux/nfsd/nfsd4_pnfs.h>
 #include "exofs.h"
 
+#include "../exportfs/pnfs_osd_xdr_srv.h"
+
 static int exofs_layout_type(struct super_block *sb)
 {
 	return LAYOUT_OSD2_OBJECTS;
Signature · 1 line
1.7.3.4
#18 lore raw

PATCH 7/10 SQUASHME: pnfsd-exofs: osd_xdr_srv header moved

In reply to Boaz Harrosh
---
 fs/exofs/export.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
fs/exofs/export.c +1 -1
index 20969bf..616cf5d 100644
@@ -27,7 +27,7 @@
 #include <linux/nfsd/nfsd4_pnfs.h>
 #include "exofs.h"
 
-#include "../exportfs/pnfs_osd_xdr_srv.h"
+#include "linux/nfsd/pnfs_osd_xdr_srv.h"
 
 static int exofs_layout_type(struct super_block *sb)
 {
Signature · 1 line
1.7.3.4
#19 lore raw

PATCH 8/10 SQUASHME: pnfsd-exofs: layout encoding was Changed to two pass

In reply to Boaz Harrosh

This way there is No need for dynamic allocation of the creds array.

---
 fs/exofs/export.c |   55 ++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 28 deletions(-)
fs/exofs/export.c +25 -26
index 616cf5d..14852d8 100644
@@ -70,44 +70,43 @@ static enum nfsstat4 exofs_layout_get(
 		goto out;
 	}
 
-	creds = kcalloc(el->s_numdevs, sizeof(*creds), GFP_KERNEL);
-	if (!creds) {
-		nfserr = NFS4ERR_LAYOUTTRYLATER;
-		goto out;
-	}
-
 	/* Fill in a pnfs_osd_layout struct */
 	layout.olo_map = sbi->data_map;
+	layout.olo_comps_index = 0;
+	layout.olo_num_comps = el->s_numdevs;
+	layout.olo_comps = creds;
+
+	err = pnfs_osd_xdr_encode_layout_hdr(xdr, &layout);
+	if (err) {
+		nfserr = NFS4ERR_TOOSMALL;
+		goto out;
+	}
 
+	/* Encode layout components */
 	for (i = 0; i < el->s_numdevs; i++) {
-		struct pnfs_osd_object_cred *cred = &creds[i];
+		struct pnfs_osd_object_cred cred;
 		osd_id id = exofs_oi_objno(oi);
 		unsigned dev = exofs_layout_od_id(el, id, i);
 
-		set_dev_id(&cred->oc_object_id.oid_device_id, args->lg_sbid,
+		set_dev_id(&cred.oc_object_id.oid_device_id, args->lg_sbid,
 			   dev);
-		cred->oc_object_id.oid_partition_id = el->s_pid;
-		cred->oc_object_id.oid_object_id = id;
-		cred->oc_osd_version = osd_dev_is_ver1(el->s_ods[dev]) ?
+		cred.oc_object_id.oid_partition_id = el->s_pid;
+		cred.oc_object_id.oid_object_id = id;
+		cred.oc_osd_version = osd_dev_is_ver1(el->s_ods[dev]) ?
 						PNFS_OSD_VERSION_1 :
 						PNFS_OSD_VERSION_2;
-		cred->oc_cap_key_sec = PNFS_OSD_CAP_KEY_SEC_NONE;
-
-		cred->oc_cap_key.cred_len	= 0;
-		cred->oc_cap_key.cred		= NULL;
+		cred.oc_cap_key_sec = PNFS_OSD_CAP_KEY_SEC_NONE;
 
-		cred->oc_cap.cred_len	= OSD_CAP_LEN;
-		cred->oc_cap.cred	= oi->i_cred;
-	}
-
-	layout.olo_comps_index = 0;
-	layout.olo_num_comps = el->s_numdevs;
-	layout.olo_comps = creds;
+		cred.oc_cap_key.cred_len	= 0;
+		cred.oc_cap_key.cred		= NULL;
 
-	err = pnfs_osd_xdr_encode_layout(xdr, &layout);
-	if (err) {
-		nfserr = NFS4ERR_TOOSMALL; /* FIXME: Change osd_xdr error codes */
-		goto out;
+		cred.oc_cap.cred_len	= OSD_CAP_LEN;
+		cred.oc_cap.cred	= oi->i_cred;
+		err = pnfs_osd_xdr_encode_layout_cred(xdr, &cred);
+		if (err) {
+			nfserr = NFS4ERR_TOOSMALL;
+			goto out;
+		}
 	}
 
 	exp_xdr_encode_opaque_len(start, xdr->p);
Signature · 1 line
1.7.3.4
#20 lore raw

PATCH 9/10 SQUASHME: pnfsd-exofs: Convert XDR API to return enum nfsstat4

In reply to Boaz Harrosh

Remove error translation from export.c, now that XDR API returns the proper constants

---
 fs/exofs/export.c |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
fs/exofs/export.c +9 -11
index 88be441..c153ad6 100644
@@ -86,7 +86,7 @@ static enum nfsstat4 exofs_layout_get(
 	struct pnfs_osd_layout layout;
 	__be32 *start;
 	bool in_recall;
-	int i, err;
+	int i;
 	enum nfsstat4 nfserr;
 
 	res->lg_seg.offset = 0;
@@ -107,11 +107,9 @@ static enum nfsstat4 exofs_layout_get(
 	layout.olo_num_comps = el->s_numdevs;
 	layout.olo_comps = creds;
 
-	err = pnfs_osd_xdr_encode_layout_hdr(xdr, &layout);
-	if (err) {
-		nfserr = NFS4ERR_TOOSMALL;
+	nfserr = pnfs_osd_xdr_encode_layout_hdr(xdr, &layout);
+	if (unlikely(nfserr))
 		goto out;
-	}
 
 	/* Encode layout components */
 	for (i = 0; i < el->s_numdevs; i++) {
@@ -133,11 +131,9 @@ static enum nfsstat4 exofs_layout_get(
 
 		cred.oc_cap.cred_len	= OSD_CAP_LEN;
 		cred.oc_cap.cred	= oi->i_cred;
-		err = pnfs_osd_xdr_encode_layout_cred(xdr, &cred);
-		if (err) {
-			nfserr = NFS4ERR_TOOSMALL;
+		nfserr = pnfs_osd_xdr_encode_layout_cred(xdr, &cred);
+		if (unlikely(nfserr))
 			goto out;
-		}
 	}
 
 	exp_xdr_encode_opaque_len(start, xdr->p);
@@ -303,13 +299,15 @@ int exofs_get_device_info(struct super_block *sb, struct exp_xdr_stream *xdr,
 	/* skip opaque size, will be filled-in later */
 	start = exp_xdr_reserve_qwords(xdr, 1);
 	if (!start) {
-		err = -E2BIG;
+		err = -ETOOSMALL;
 		goto err;
 	}
 
 	err = pnfs_osd_xdr_encode_deviceaddr(xdr, &devaddr);
-	if (err)
+	if (err) {
+		err = -ETOOSMALL;
 		goto err;
+	}
 
 	exp_xdr_encode_opaque_len(start, xdr->p);
 
Signature · 1 line
1.7.3.4
#21 lore raw

PATCH 10/10 SQUASHME: pnfsd-exofs: checkpatch love and a dprint

In reply to Boaz Harrosh

---

fs/exofs/export.c +5 -2
index c153ad6..8281c85 100644
@@ -85,8 +85,8 @@ static enum nfsstat4 exofs_layout_get(
 	struct pnfs_osd_object_cred *creds = NULL;
 	struct pnfs_osd_layout layout;
 	__be32 *start;
+	unsigned i;
 	bool in_recall;
-	int i;
 	enum nfsstat4 nfserr;
 
 	res->lg_seg.offset = 0;
@@ -285,8 +285,11 @@ int exofs_get_device_info(struct super_block *sb, struct exp_xdr_stream *xdr,
 
 	memset(&devaddr, 0, sizeof(devaddr));
 
-	if (unlikely(devno >= sbi->layout.s_numdevs))
+	if (unlikely(devno >= sbi->layout.s_numdevs)) {
+		EXOFS_DBGMSG("Error: Device((%llx,%llx) does not exist\n",
+			     devid->sbid, devno);
 		return -ENODEV;
+	}
 
 	odi = osduld_device_info(sbi->layout.s_ods[devno]);
 
fs/exportfs/pnfs_osd_xdr_srv.c +37 -37

125 lines not on this page · raw message

include/linux/nfsd/pnfs_osd_xdr_srv.h +1 -1
index 2909fbe..fab244e 100644
@@ -30,7 +30,7 @@ enum nfsstat4 pnfs_osd_xdr_encode_deviceaddr(
 	struct exp_xdr_stream *xdr, struct pnfs_osd_deviceaddr *devaddr);
 
 /* layout_commit decoding */
-__be32 * pnfs_osd_xdr_decode_layoutupdate(
+__be32 *pnfs_osd_xdr_decode_layoutupdate(
 	struct pnfs_osd_layoutupdate *lou, __be32 *p);
 
 /* layout_return decoding */