[PATCH 01/13] SQUASHME: pnfsd: add missing nfs4_unlock_state in
[PATCH 02/13] DEBUG: pnfsd: printouts
[PATCH 03/13] pnfsd-block: reverse boolean_t values so they make
[PATCH 04/13] pnfsd-block: mv include/linux/nfsd4_block.h
[PATCH 05/13] pnfsd-block: do not override s_pnfs_op
[PATCH 06/13] pnfsd-block: change blr_lock to mutex
[PATCH 07/13] pnfsd-block: dprint fiemap rval
[PATCH 08/13] pnfsd-block: allow positive fiemap rval
[PATCH 09/13] pnfsd-block: use SECT_SIZE helper macros
[PATCH 10/13] pnfsd-block: undo dependence on spnfs
[PATCH 11/13] pnfsd-block: set the sbid part of the deviceid
[PATCH 12/13] DEBUG: pnfs: printouts
[PATCH 13/13] DEBUG: pnfsblock: add devid debug printouts
From: Benny Halevy <[email protected]>
---
fs/nfs/nfs4xdr.c | 2 ++
fs/nfs/pnfs.c | 4 +++-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index e6161b2..0bda77e 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4448,6 +4448,7 @@ static int decode_first_pnfs_layout_type(struct xdr_stream *xdr,
/* pNFS is not supported by the underlying file system */
if (num == 0) {
+ dprintk("%s: num=0\n", __func__);
*layouttype = 0;
return 0;
}
@@ -4460,6 +4461,7 @@ static int decode_first_pnfs_layout_type(struct xdr_stream *xdr,
if (unlikely(!p))
goto out_overflow;
*layouttype = be32_to_cpup(p);
+ dprintk("%s: layouttype=0x%x\n", __func__, *layouttype);
return 0;
out_overflow:
print_overflow_msg(__func__, xdr);
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index baf7353..61778c9 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -97,8 +97,10 @@
{
struct pnfs_layoutdriver_type *ld_type = NULL;
- if (id == 0)
+ if (id == 0) {
+ dprintk("%s: layout type %u\n", __func__, id);
goto out_no_driver;
+ }
if (!(server->nfs_client->cl_exchange_flags &
(EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) {
printk(KERN_ERR "%s: id %u cl_exchange_flags 0x%x\n", __func__,
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/Kconfig | 6 +++---
fs/nfsd/Makefile | 2 +-
fs/nfsd/bl_com.c | 3 ---
fs/nfsd/bl_ops.c | 13 +++++--------
fs/nfsd/export.c | 27 +++++++++++++++------------
fs/nfsd/nfs4proc.c | 20 +++++++-------------
fs/nfsd/nfsctl.c | 8 ++------
fs/nfsd/vfs.c | 9 ++-------
include/linux/nfsd/nfsd4_block.h | 8 +++++++-
9 files changed, 42 insertions(+), 54 deletions(-)
diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig
index e707145..071bdbf 100644
--- a/fs/nfsd/Kconfig
+++ b/fs/nfsd/Kconfig
@@ -141,11 +141,11 @@ config SPNFS_LAYOUTSEGMENTS
If unsure, say N.
-config SPNFS_BLOCK
+config PNFSD_BLOCK
bool "Provide Block Layout server support (EXPERIMENTAL)"
- depends on SPNFS
+ depends on PNFSD
select EXPORTFS_BLOCK_LAYOUT
help
- Say Y here if you want spNFS block layout support
+ Say Y here if you want pNFS block layout support
If unsure, say N.
diff --git a/fs/nfsd/Makefile b/fs/nfsd/Makefile
index fed6c25..d2e7f43 100644
--- a/fs/nfsd/Makefile
+++ b/fs/nfsd/Makefile
@@ -14,4 +14,4 @@ nfsd-$(CONFIG_NFSD_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \
nfsd-$(CONFIG_PNFSD) += nfs4pnfsd.o nfs4pnfsdlm.o nfs4pnfsds.o
nfsd-$(CONFIG_PNFSD_LOCAL_EXPORT) += pnfsd_lexp.o
nfsd-$(CONFIG_SPNFS) += spnfs_com.o spnfs_ops.o
-nfsd-$(CONFIG_SPNFS_BLOCK) += bl_com.o bl_ops.o
+nfsd-$(CONFIG_PNFSD_BLOCK) += bl_com.o bl_ops.o
diff --git a/fs/nfsd/bl_com.c b/fs/nfsd/bl_com.c
index 388d71a..2199725 100644
--- a/fs/nfsd/bl_com.c
+++ b/fs/nfsd/bl_com.c
@@ -1,5 +1,3 @@
-#if defined(CONFIG_SPNFS_BLOCK)
-
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/init.h>
@@ -289,4 +287,3 @@ static ssize_t ctl_write(struct file *file, const char __user *buf, size_t len,
return 0;
}
-#endif /* CONFIG_SPNFS_BLOCK */
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 31e23c2..f5980a3 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -13,7 +13,6 @@
* These functions, with the exception of pnfs_block_enabled, are assigned to
* the super block s_export_op structure.
*/
-#if defined(CONFIG_SPNFS_BLOCK)
#include <linux/module.h>
#include <linux/genhd.h>
@@ -139,7 +138,7 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
* pnfs_block_enabled -- check to see if this file system should be export as
* block pnfs
*/
-int
+bool
pnfs_block_enabled(struct inode *inode, int ex_flags)
{
bl_comm_msg_t msg;
@@ -159,7 +158,7 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
#ifdef notyet
if (!(ex_flags & NFSEXP_PNFS_BLOCK)) {
dprintk("%s: pnfs_block not set in export\n", __func__);
- return 0;
+ return false;
}
#endif
@@ -170,13 +169,13 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
if (bl_upcall(bl_comm_global, &msg, &res)) {
dprintk("%s: Failed to contact pNFS block daemon\n",
__func__);
- return 0;
+ return false;
}
if (msg.u.msg_vers != res->u.vers) {
dprintk("%s: vers mismatch, kernel != daemon\n",
__func__);
kfree(res);
- return 0;
+ return false;
}
}
bl_comm_once = 1;
@@ -184,7 +183,7 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
kfree(res);
dprintk("<-- %s okay\n", __func__);
- return 1;
+ return true;
}
int
@@ -1677,5 +1676,3 @@ struct list_head *
}
return True;
}
-
-#endif /* CONFIG_SPNFS_BLOCK */
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index a12d7a9..10b61b6 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -16,11 +16,9 @@
#include <linux/module.h>
#include <linux/exportfs.h>
#include <linux/nfsd/nfsd4_pnfs.h>
+#include <linux/nfsd/nfsd4_block.h>
#if defined(CONFIG_SPNFS)
#include <linux/nfsd4_spnfs.h>
-#if defined(CONFIG_SPNFS_BLOCK)
-#include <linux/nfsd/nfsd4_block.h>
-#endif
#endif
#include <net/ipv6.h>
@@ -374,7 +372,8 @@ static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)
.get_state = spnfs_get_state,
};
-#if defined(CONFIG_SPNFS_BLOCK)
+#endif /* CONFIG_SPNFS */
+#if defined(CONFIG_PNFSD_BLOCK)
static struct pnfs_export_operations bl_export_ops = {
.layout_type = bl_layout_type,
.get_device_info = bl_getdeviceinfo,
@@ -382,8 +381,7 @@ static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)
.layout_get = bl_layoutget,
.layout_return = bl_layoutreturn,
};
-#endif /* CONFIG_SPNFS_BLOCK */
-#endif /* CONFIG_SPNFS */
+#endif /* CONFIG_PNFSD_BLOCK */
#endif /* CONFIG_PNFSD */
static struct svc_export *svc_export_update(struct svc_export *new,
@@ -400,13 +398,18 @@ static int pnfsd_check_export(struct inode *inode, int *flags)
return 0;
#endif /* CONFIG_PNFSD_LOCAL_EXPORT */
+ if (pnfs_block_enabled(inode, *flags)) {
+ if (!inode->i_sb->s_pnfs_op) {
+ dprintk("set pnfs block export structure\n");
+ inode->i_sb->s_pnfs_op = &bl_export_ops;
+ } else
+ dprintk("pnfs block enabled, fs provided s_pnfs_op\n");
+ dprintk("pnfs block enabled, sb=%p s_pnfs_op=%p\n",
+ inode->i_sb, inode->i_sb->s_pnfs_op);
+ return 0;
+ }
+
#if defined(CONFIG_SPNFS)
-#if defined(CONFIG_SPNFS_BLOCK)
- if (!inode->i_sb->s_pnfs_op && pnfs_block_enabled(inode, *flags)) {
- dprintk("set pnfs block export structure... \n");
- inode->i_sb->s_pnfs_op = &bl_export_ops;
- } else
-#endif /* CONFIG_SPNFS_BLOCK */
/*
* spnfs_enabled() indicates we're an MDS.
* XXX Better to check an export time option as well.
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 501781d..b887690 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -924,18 +924,6 @@ static __be32 nfsd4_do_lookupp(struct svc_rqst *rqstp, struct svc_fh *fh)
nfsd4_get_verifier(cstate->current_fh.fh_dentry->d_inode->i_sb,
&write->wr_verifier);
#if defined(CONFIG_SPNFS)
-#if defined(CONFIG_SPNFS_BLOCK)
- if (pnfs_block_enabled(cstate->current_fh.fh_dentry->d_inode, 0)) {
- status = bl_layoutrecall(cstate->current_fh.fh_dentry->d_inode,
- RETURN_FILE, write->wr_offset, write->wr_buflen, false);
- if (!status) {
- status = nfsd_write(rqstp, &cstate->current_fh, filp,
- write->wr_offset, rqstp->rq_vec, write->wr_vlen,
- &cnt, &write->wr_how_written);
- }
- } else
-#endif
-
if (spnfs_enabled()) {
status = spnfs_write(cstate->current_fh.fh_dentry->d_inode,
write->wr_offset, write->wr_buflen, write->wr_vlen,
@@ -958,11 +946,17 @@ static __be32 nfsd4_do_lookupp(struct svc_rqst *rqstp, struct svc_fh *fh)
write->wr_offset, rqstp->rq_vec, write->wr_vlen,
&cnt, &write->wr_how_written);
#else
+ if (pnfs_block_enabled(cstate->current_fh.fh_dentry->d_inode, 0)) {
+ status = bl_layoutrecall(cstate->current_fh.fh_dentry->d_inode,
+ RETURN_FILE, write->wr_offset, write->wr_buflen, false);
+ if (status)
+ goto out_put;
+ }
status = nfsd_write(rqstp, &cstate->current_fh, filp,
write->wr_offset, rqstp->rq_vec, write->wr_vlen,
&cnt, &write->wr_how_written);
+out_put:
#endif /* CONFIG_SPNFS */
-
if (filp)
fput(filp);
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 02a6ddd..29cfbea 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -15,6 +15,7 @@
#include <linux/sunrpc/gss_krb5_enctypes.h>
#include <linux/module.h>
#include <linux/nfsd/nfs4pnfsdlm.h>
+#include <linux/nfsd/nfsd4_block.h>
#include "idmap.h"
#include "nfsd.h"
@@ -1203,9 +1204,6 @@ static int create_proc_exports_entry(void)
}
#endif
-#if defined(CONFIG_SPNFS_BLOCK)
-int nfsd_bl_init(void);
-#endif
static int __init init_nfsd(void)
{
int retval;
@@ -1232,10 +1230,8 @@ static int __init init_nfsd(void)
retval = spnfs_init_proc();
if (retval != 0)
goto out_free_idmap;
-#if defined(CONFIG_SPNFS_BLOCK)
- nfsd_bl_init();
-#endif /* CONFIG_SPNFS_BLOCK */
#endif /* CONFIG_PROC_FS && CONFIG_SPNFS */
+ nfsd_bl_init();
retval = register_filesystem(&nfsd_fs_type);
if (retval)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ce07f67..da18d1d 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -38,10 +38,8 @@
#include "idmap.h"
#include "pnfsd.h"
#include <linux/nfsd4_spnfs.h>
-#endif /* CONFIG_NFSD_V4 */
-#if defined(CONFIG_SPNFS_BLOCK)
#include <linux/nfsd/nfsd4_block.h>
-#endif
+#endif /* CONFIG_NFSD_V4 */
#include "nfsd.h"
#include "vfs.h"
@@ -388,13 +386,10 @@ static int nfsd_break_lease(struct inode *inode)
if (is_inode_pnfsd_lexp(inode))
pnfsd_lexp_recall_layout(inode, with_nfs4_state_lock);
#endif /* CONFIG_PNFSD_LOCAL_EXPORT */
-#if defined(CONFIG_SPNFS_BLOCK)
- if (pnfs_block_enabled(inode, 0)) {
+ if (pnfs_block_enabled(inode, 0))
err = bl_layoutrecall(inode, RETURN_FILE,
iap->ia_size, inode->i_size - iap->ia_size,
with_nfs4_state_lock);
- }
-#endif /* CONFIG_SPNFS_BLOCK */
}
host_err = get_write_access(inode);
diff --git a/include/linux/nfsd/nfsd4_block.h b/include/linux/nfsd/nfsd4_block.h
index b8a8e44..4daae91 100644
--- a/include/linux/nfsd/nfsd4_block.h
+++ b/include/linux/nfsd/nfsd4_block.h
@@ -75,7 +75,13 @@
bl_comm_msg_t msg;
} bl_comm_t;
-int pnfs_block_enabled(struct inode *, int);
+#ifdef CONFIG_PNFSD_BLOCK
+bool pnfs_block_enabled(struct inode *, int);
+void nfsd_bl_init(void);
+#else
+static inline bool pnfs_block_enabled(struct inode *, int) { return false; }
+static inline void nfsd_bl_init(void) {}
+#endif /* CONFIG_PNFSD_BLOCK */
int bl_layout_type(struct super_block *sb);
int bl_getdeviceiter(struct super_block *, u32 layout_type,
struct nfsd4_pnfs_dev_iter_res *);
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 52ac073..0c3a536 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -1302,7 +1302,7 @@ struct list_head *
(1 << i->i_sb->s_blocksize_bits) - 1);
set_fs(old_fs);
- if (rval || !fei->fi_extents_mapped) {
+ if (rval < 0 || !fei->fi_extents_mapped) {
dprintk(" No extents. Wanted %d, got %d: rval=%d\n",
fei->fi_extents_max, fei->fi_extents_mapped, rval);
kfree(fe);
--
1.7.6
On Tue, Dec 06, 2011 at 01:27:53PM +0200, Benny Halevy wrote:
> On 2011-12-06 04:10, J. Bruce Fields wrote:
> > On Sun, Dec 04, 2011 at 03:48:16PM +0200, Benny Halevy wrote:
> >> From: Benny Halevy <[email protected]>
> >>
> >> Signed-off-by: Benny Halevy <[email protected]>
> >> ---
> >> fs/nfsd/bl_ops.c | 2 +-
> >> 1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
> >> index 89249c4..4d2939e 100644
> >> --- a/fs/nfsd/bl_ops.c
> >> +++ b/fs/nfsd/bl_ops.c
> >> @@ -57,7 +57,7 @@
> >> #endif
> >>
> >>
> >> -typedef enum {True, False} boolean_t;
> >> +typedef enum {False = 0, True = !False} boolean_t;
> >
> > Shouldn't we just use "bool"?
>
> Yes, in some cases. In others, the boolean status doesn't make sense
> and I'd like to replace it with an integer.
I believe casts from bools to integers are defined to convert false and
true to 0 and 1 respectively, so you should be fine.
--b.
From: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 1 +
fs/nfsd/nfs4xdr.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 22875fb..89249c4 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -184,6 +184,7 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
int
bl_layout_type(struct super_block *sb)
{
+ dprintk("%s --> %d\n", __func__, LAYOUT_BLOCK_VOLUME);
return LAYOUT_BLOCK_VOLUME;
}
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2263830..bd8e693 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2592,6 +2592,8 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
if (sb && sb->s_pnfs_op && sb->s_pnfs_op->layout_type)
type = sb->s_pnfs_op->layout_type(sb);
+ dprintk("%s: sb=%p s_pnfs_op=%p layout_type()=%p layout_type=%u\n",
+ __func__, sb, sb->s_pnfs_op, sb->s_pnfs_op ? sb->s_pnfs_op->layout_type : NULL, type);
if (type) {
if ((buflen -= 4) < 0) /* type */
goto out_resource;
@@ -2604,6 +2606,7 @@ static __be32 fattr_handle_absent_fs(u32 *bmval0, u32 *bmval1, u32 *rdattr_err)
if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) {
if ((buflen -= 4) < 0)
goto out_resource;
+ dprintk("%s: layout_blksize=%lu\n", __func__, stat.blksize);
WRITE32(stat.blksize);
}
#endif /* CONFIG_PNFSD */
--
1.7.6
On Sun, Dec 04, 2011 at 03:48:16PM +0200, Benny Halevy wrote:
> From: Benny Halevy <[email protected]>
>
> Signed-off-by: Benny Halevy <[email protected]>
> ---
> fs/nfsd/bl_ops.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
> index 89249c4..4d2939e 100644
> --- a/fs/nfsd/bl_ops.c
> +++ b/fs/nfsd/bl_ops.c
> @@ -57,7 +57,7 @@
> #endif
>
>
> -typedef enum {True, False} boolean_t;
> +typedef enum {False = 0, True = !False} boolean_t;
Shouldn't we just use "bool"?
--b.
> /* ---- block layoutget and commit structure ---- */
> typedef struct bl_layout_rec {
> struct list_head blr_hash,
> --
> 1.7.6
>
> --
> 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
On 2011-12-06 04:12, J. Bruce Fields wrote:
> On Sun, Dec 04, 2011 at 03:48:28PM +0200, Benny Halevy wrote:
>> From: Benny Halevy <[email protected]>
>>
>> Signed-off-by: Benny Halevy <[email protected]>
>> ---
>> fs/nfsd/bl_com.c | 2 +-
>> fs/nfsd/bl_ops.c | 2 +-
>> fs/nfsd/export.c | 2 +-
>> fs/nfsd/nfs4proc.c | 2 +-
>> fs/nfsd/nfs4xdr.c | 2 +-
>> fs/nfsd/vfs.c | 2 +-
>> include/linux/{ => nfsd}/nfsd4_block.h | 0
>> 7 files changed, 6 insertions(+), 6 deletions(-)
>> rename include/linux/{ => nfsd}/nfsd4_block.h (100%)
>
> As long as this is only used in fs/nfsd, let's put this header file
> in fs/nfsd.
Agreed.
Benny
>
> --b.
>
>>
>> diff --git a/fs/nfsd/bl_com.c b/fs/nfsd/bl_com.c
>> index cf37814..388d71a 100644
>> --- a/fs/nfsd/bl_com.c
>> +++ b/fs/nfsd/bl_com.c
>> @@ -19,7 +19,7 @@
>> #include <linux/nfs_fs.h>
>>
>> #include <linux/nfsd/debug.h>
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>>
>> #define NFSDDBG_FACILITY NFSDDBG_PNFS
>>
>> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
>> index 4d2939e..15d2604 100644
>> --- a/fs/nfsd/bl_ops.c
>> +++ b/fs/nfsd/bl_ops.c
>> @@ -28,7 +28,7 @@
>> #include <linux/dm-ioctl.h>
>> #include <asm/uaccess.h>
>> #include <linux/falloc.h>
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>>
>> #include "pnfsd.h"
>>
>> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
>> index 10a05de..9585795 100644
>> --- a/fs/nfsd/export.c
>> +++ b/fs/nfsd/export.c
>> @@ -19,7 +19,7 @@
>> #if defined(CONFIG_SPNFS)
>> #include <linux/nfsd4_spnfs.h>
>> #if defined(CONFIG_SPNFS_BLOCK)
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>> #endif
>> #endif
>> #include <net/ipv6.h>
>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>> index e4745ca..501781d 100644
>> --- a/fs/nfsd/nfs4proc.c
>> +++ b/fs/nfsd/nfs4proc.c
>> @@ -36,7 +36,7 @@
>> #include <linux/slab.h>
>> #include <linux/nfsd/nfs4layoutxdr.h>
>> #include <linux/nfsd4_spnfs.h>
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>>
>> #include "idmap.h"
>> #include "cache.h"
>> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
>> index bd8e693..cebd5a2 100644
>> --- a/fs/nfsd/nfs4xdr.c
>> +++ b/fs/nfsd/nfs4xdr.c
>> @@ -49,7 +49,7 @@
>> #include <linux/exportfs.h>
>> #include <linux/nfsd/nfs4layoutxdr.h>
>> #include <linux/nfsd4_spnfs.h>
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>>
>> #include "idmap.h"
>> #include "acl.h"
>> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
>> index 43efbdc..ce07f67 100644
>> --- a/fs/nfsd/vfs.c
>> +++ b/fs/nfsd/vfs.c
>> @@ -40,7 +40,7 @@
>> #include <linux/nfsd4_spnfs.h>
>> #endif /* CONFIG_NFSD_V4 */
>> #if defined(CONFIG_SPNFS_BLOCK)
>> -#include <linux/nfsd4_block.h>
>> +#include <linux/nfsd/nfsd4_block.h>
>> #endif
>>
>> #include "nfsd.h"
>> diff --git a/include/linux/nfsd4_block.h b/include/linux/nfsd/nfsd4_block.h
>> similarity index 100%
>> rename from include/linux/nfsd4_block.h
>> rename to include/linux/nfsd/nfsd4_block.h
>> --
>> 1.7.6
>>
>> --
>> 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
> --
> 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
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_com.c | 2 +-
fs/nfsd/bl_ops.c | 2 +-
fs/nfsd/export.c | 2 +-
fs/nfsd/nfs4proc.c | 2 +-
fs/nfsd/nfs4xdr.c | 2 +-
fs/nfsd/vfs.c | 2 +-
include/linux/{ => nfsd}/nfsd4_block.h | 0
7 files changed, 6 insertions(+), 6 deletions(-)
rename include/linux/{ => nfsd}/nfsd4_block.h (100%)
diff --git a/fs/nfsd/bl_com.c b/fs/nfsd/bl_com.c
index cf37814..388d71a 100644
--- a/fs/nfsd/bl_com.c
+++ b/fs/nfsd/bl_com.c
@@ -19,7 +19,7 @@
#include <linux/nfs_fs.h>
#include <linux/nfsd/debug.h>
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#define NFSDDBG_FACILITY NFSDDBG_PNFS
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 4d2939e..15d2604 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -28,7 +28,7 @@
#include <linux/dm-ioctl.h>
#include <asm/uaccess.h>
#include <linux/falloc.h>
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#include "pnfsd.h"
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 10a05de..9585795 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -19,7 +19,7 @@
#if defined(CONFIG_SPNFS)
#include <linux/nfsd4_spnfs.h>
#if defined(CONFIG_SPNFS_BLOCK)
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#endif
#endif
#include <net/ipv6.h>
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index e4745ca..501781d 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -36,7 +36,7 @@
#include <linux/slab.h>
#include <linux/nfsd/nfs4layoutxdr.h>
#include <linux/nfsd4_spnfs.h>
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#include "idmap.h"
#include "cache.h"
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index bd8e693..cebd5a2 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -49,7 +49,7 @@
#include <linux/exportfs.h>
#include <linux/nfsd/nfs4layoutxdr.h>
#include <linux/nfsd4_spnfs.h>
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#include "idmap.h"
#include "acl.h"
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 43efbdc..ce07f67 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -40,7 +40,7 @@
#include <linux/nfsd4_spnfs.h>
#endif /* CONFIG_NFSD_V4 */
#if defined(CONFIG_SPNFS_BLOCK)
-#include <linux/nfsd4_block.h>
+#include <linux/nfsd/nfsd4_block.h>
#endif
#include "nfsd.h"
diff --git a/include/linux/nfsd4_block.h b/include/linux/nfsd/nfsd4_block.h
similarity index 100%
rename from include/linux/nfsd4_block.h
rename to include/linux/nfsd/nfsd4_block.h
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 0c3a536..31e23c2 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -44,9 +44,15 @@
#define bl_layout_hashval(id) \
((id) & BL_LAYOUT_HASH_MASK)
+#define BL_SECT_SHIFT 9
+#define BL_SECT_SIZE (1 << BL_SECT_SHIFT)
+#define BL_SECT_MASK (~(BL_SECT_SIZE - 1))
+#define BL_SECT_ALIGN(x) ALIGN((x), BL_SECT_SIZE)
+
#define BLL_F_END(p) ((p)->bll_foff + (p)->bll_len)
#define BLL_S_END(p) ((p)->bll_soff + (p)->bll_len)
-#define _2SECTS(v) ((v) >> 9)
+#define _2SECTS(v) ((v) >> BL_SECT_SHIFT)
+#define _2BYTES(v) ((unsigned long long)(v) << BL_SECT_SHIFT)
#ifndef READ32
#define READ32(x) (x) = ntohl(*p++)
@@ -274,9 +280,9 @@ static boolean_t extents_process(struct fiemap_extent_info *fei,
memset(bld, 0, sizeof (*bld));
bld->bld_type = PNFS_BLOCK_VOLUME_STRIPE;
bld->u.stripe.bld_stripes = res->u.stripe.num_stripes;
- bld->u.stripe.bld_chunk_size = res->u.stripe.stripe_size * 512LL;
+ bld->u.stripe.bld_chunk_size = _2BYTES(res->u.stripe.stripe_size);
dprintk("%s: stripes %d, chunk_size %Lu\n", __func__,
- bld->u.stripe.bld_stripes, bld->u.stripe.bld_chunk_size / 512LL);
+ bld->u.stripe.bld_stripes, _2SECTS(bld->u.stripe.bld_chunk_size));
bld->u.stripe.bld_stripe_indexs = kmalloc(bld->u.stripe.bld_stripes *
sizeof (int), GFP_KERNEL);
@@ -381,10 +387,10 @@ enum nfsstat4
(res->lg_seg.iomode == IOMODE_READ)))
res->lg_seg.length = i->i_size - res->lg_seg.offset;
- adj = (res->lg_seg.offset & 511) ? res->lg_seg.offset & 511 : 0;
+ adj = res->lg_seg.offset & ~BL_SECT_MASK;
res->lg_seg.offset -= adj;
- res->lg_seg.length = (res->lg_seg.length + adj + 511) & ~511;
-
+ res->lg_seg.length = BL_SECT_ALIGN(res->lg_seg.length + adj);
+
if (res->lg_seg.iomode != IOMODE_READ)
if (i->i_op->fallocate(i, FALLOC_FL_KEEP_SIZE,
res->lg_seg.offset, res->lg_seg.length))
@@ -679,7 +685,7 @@ enum nfsstat4
if (!bld)
return NULL;
- bld->u.simple.bld_offset = (res->u.sig.sector * 512LL) + res->u.sig.offset;
+ bld->u.simple.bld_offset = _2BYTES(res->u.sig.sector) + res->u.sig.offset;
bld->u.simple.bld_sig_len = res->u.sig.len;
bld->u.simple.bld_sig = kmalloc(res->u.sig.len, GFP_KERNEL);
if (!bld->u.simple.bld_sig)
@@ -727,12 +733,12 @@ enum nfsstat4
bld->bld_devid.devid = devid;
bld->bld_index_loc = my_loc;
- bld->u.slice.bld_start = res->u.slice.start * 512LL;
- bld->u.slice.bld_len = res->u.slice.length * 512LL;
+ bld->u.slice.bld_start = _2BYTES(res->u.slice.start);
+ bld->u.slice.bld_len = _2BYTES(res->u.slice.length);
bld->u.slice.bld_index = simple_loc;
dprintk("%s: start %Lu, len %Lu\n", __func__,
- bld->u.slice.bld_start / 512LL, bld->u.slice.bld_len / 512LL);
+ _2SECTS(bld->u.slice.bld_start), _2SECTS(bld->u.slice.bld_len));
kfree(res);
dprintk("<-- %s (rval %p)\n", __func__, bld);
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/export.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 9585795..a12d7a9 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -402,7 +402,7 @@ static int pnfsd_check_export(struct inode *inode, int *flags)
#if defined(CONFIG_SPNFS)
#if defined(CONFIG_SPNFS_BLOCK)
- if (pnfs_block_enabled(inode, *flags)) {
+ if (!inode->i_sb->s_pnfs_op && pnfs_block_enabled(inode, *flags)) {
dprintk("set pnfs block export structure... \n");
inode->i_sb->s_pnfs_op = &bl_export_ops;
} else
--
1.7.6
From: Benny Halevy <[email protected]>
We're allocating memory while holding blr_lock
via bl_layoutget -> layout_cache_fill_from -> bll_alloc
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 15d2604..5f20b90 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -68,7 +68,7 @@
u64 blr_orig_size,
blr_commit_size,
blr_ext_size;
- spinlock_t blr_lock; // Protects blr_layouts
+ struct mutex blr_lock; // Protects blr_layouts
} bl_layout_rec_t;
static struct list_head layout_hash;
@@ -401,7 +401,7 @@ enum nfsstat4
}
BUG_ON(!r);
- spin_lock(&r->blr_lock);
+ mutex_lock(&r->blr_lock);
if (layout_cache_fill_from(r, &bl_possible, &res->lg_seg)) {
/*
@@ -443,7 +443,7 @@ enum nfsstat4
}
}
- spin_unlock(&r->blr_lock);
+ mutex_unlock(&r->blr_lock);
if (unlikely(nfserr)) {
if (del_on_error == True)
layout_inode_del(i);
@@ -541,9 +541,9 @@ enum nfsstat4
r = layout_inode_find(i);
if (r) {
- spin_lock(&r->blr_lock);
+ mutex_lock(&r->blr_lock);
layout_cache_del(r, &args->lr_seg);
- spin_unlock(&r->blr_lock);
+ mutex_unlock(&r->blr_lock);
dprintk(" ext_size %Lu, i_size %Lu, orig_size %Lu\n",
r->blr_ext_size, i->i_size, r->blr_orig_size);
}
@@ -591,7 +591,7 @@ enum nfsstat4
restart:
r = layout_inode_find(inode);
if (r && len && !r->blr_recalled) {
- spin_lock(&r->blr_lock);
+ mutex_lock(&r->blr_lock);
list_for_each_entry(b, &r->blr_layouts, bll_list) {
if (!r->blr_recalled && !b->bll_recalled &&
(offset >= b->bll_foff) && (offset < BLL_F_END(b))) {
@@ -624,14 +624,14 @@ enum nfsstat4
* the lock. The request will come in on the
* same thread which will cause a deadlock.
*/
- spin_unlock(&r->blr_lock);
+ mutex_unlock(&r->blr_lock);
_nfsd_layout_recall_cb(sb, inode, &lr, with_nfs4_state_lock);
adj = MIN(b->bll_len - (offset - b->bll_foff),
len);
offset += adj;
len -= adj;
if (!len) {
- spin_lock(&r->blr_lock);
+ mutex_lock(&r->blr_lock);
break;
}
/*
@@ -642,7 +642,7 @@ enum nfsstat4
goto restart;
}
}
- spin_unlock(&r->blr_lock);
+ mutex_unlock(&r->blr_lock);
}
dprintk("<-- %s\n", __func__);
@@ -1451,7 +1451,7 @@ struct list_head *
r->blr_ext_size = 0;
r->blr_recalled = 0;
INIT_LIST_HEAD(&r->blr_layouts);
- spin_lock_init(&r->blr_lock);
+ mutex_init(&r->blr_lock);
spin_lock(&layout_hashtbl_lock);
list_add_tail(&r->blr_hash, &layout_hash);
spin_unlock(&layout_hashtbl_lock);
@@ -1500,13 +1500,12 @@ struct list_head *
spin_lock(&layout_hashtbl_lock);
r = __layout_inode_find(i);
if (r) {
- spin_lock(&r->blr_lock);
+ /* FIXME: cannot acquire mutex while holding a spin lock
+ * need kref?
+ */
if (list_empty(&r->blr_layouts)) {
list_del(&r->blr_hash);
- spin_unlock(&r->blr_lock);
kfree(r);
- } else {
- spin_unlock(&r->blr_lock);
}
} else {
dprintk("%s: failed to find inode [0x%x:%lu] in table for delete\n",
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 5f20b90..52ac073 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -1303,8 +1303,8 @@ struct list_head *
set_fs(old_fs);
if (rval || !fei->fi_extents_mapped) {
- dprintk(" No extents. Wanted %d, got %d\n",
- fei->fi_extents_max, fei->fi_extents_mapped);
+ dprintk(" No extents. Wanted %d, got %d: rval=%d\n",
+ fei->fi_extents_max, fei->fi_extents_mapped, rval);
kfree(fe);
fei->fi_extents_start = NULL;
return False;
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index 89249c4..4d2939e 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -57,7 +57,7 @@
#endif
-typedef enum {True, False} boolean_t;
+typedef enum {False = 0, True = !False} boolean_t;
/* ---- block layoutget and commit structure ---- */
typedef struct bl_layout_rec {
struct list_head blr_hash,
--
1.7.6
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/nfs4pnfsd.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index d77df33..42e2bb0 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -989,6 +989,7 @@ int nfs4_pnfs_return_layout(struct super_block *sb, struct svc_fh *current_fh,
if (lrp->args.lr_return_type == RETURN_FILE) {
fp = find_file(ino);
if (!fp) {
+ nfs4_unlock_state();
dprintk("%s: RETURN_FILE: no nfs4_file for ino %p:%lu\n",
__func__, ino, ino ? ino->i_ino : 0L);
/* If we had a layout on the file the nfs4_file would
--
1.7.6
On 2011-12-06 04:10, J. Bruce Fields wrote:
> On Sun, Dec 04, 2011 at 03:48:16PM +0200, Benny Halevy wrote:
>> From: Benny Halevy <[email protected]>
>>
>> Signed-off-by: Benny Halevy <[email protected]>
>> ---
>> fs/nfsd/bl_ops.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
>> index 89249c4..4d2939e 100644
>> --- a/fs/nfsd/bl_ops.c
>> +++ b/fs/nfsd/bl_ops.c
>> @@ -57,7 +57,7 @@
>> #endif
>>
>>
>> -typedef enum {True, False} boolean_t;
>> +typedef enum {False = 0, True = !False} boolean_t;
>
> Shouldn't we just use "bool"?
Yes, in some cases. In others, the boolean status doesn't make sense
and I'd like to replace it with an integer.
Benny
>
> --b.
>
>> /* ---- block layoutget and commit structure ---- */
>> typedef struct bl_layout_rec {
>> struct list_head blr_hash,
>> --
>> 1.7.6
>>
>> --
>> 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
> --
> 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
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfs/blocklayout/blocklayout.c | 4 +++-
fs/nfs/blocklayout/blocklayoutdev.c | 14 ++++++++++----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 3fdfb29..b6068f8 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -900,7 +900,9 @@ static void free_blk_mountid(struct block_mount_id *mid)
dev->pglen = PAGE_SIZE * max_pages;
dev->mincount = 0;
- dprintk("%s: dev_id: %s\n", __func__, dev->dev_id.data);
+ dprintk("%s: dev_id: (%x:%x:%x:%x)\n", __func__,
+ ((unsigned *)dev->dev_id.data)[0], ((unsigned *)dev->dev_id.data)[1],
+ ((unsigned *)dev->dev_id.data)[2], ((unsigned *)dev->dev_id.data)[3]);
rc = nfs4_proc_getdeviceinfo(server, dev);
dprintk("%s getdevice info returns %d\n", __func__, rc);
if (rc) {
diff --git a/fs/nfs/blocklayout/blocklayoutdev.c b/fs/nfs/blocklayout/blocklayoutdev.c
index d08ba91..34f97c9 100644
--- a/fs/nfs/blocklayout/blocklayoutdev.c
+++ b/fs/nfs/blocklayout/blocklayoutdev.c
@@ -122,7 +122,9 @@ struct pnfs_block_dev *
int offset, len, i, rc;
dprintk("%s CREATING PIPEFS MESSAGE\n", __func__);
- dprintk("%s: deviceid: %s, mincount: %d\n", __func__, dev->dev_id.data,
+ dprintk("%s: dev_id: (%x:%x:%x:%x), mincount: %d\n", __func__,
+ ((unsigned *)dev->dev_id.data)[0], ((unsigned *)dev->dev_id.data)[1],
+ ((unsigned *)dev->dev_id.data)[2], ((unsigned *)dev->dev_id.data)[3],
dev->mincount);
memset(&msg, 0, sizeof(msg));
@@ -181,10 +183,12 @@ struct pnfs_block_dev *
rv->bm_mdev = bd;
memcpy(&rv->bm_mdevid, &dev->dev_id, sizeof(struct nfs4_deviceid));
- dprintk("%s Created device %s with bd_block_size %u\n",
+ dprintk("%s Created device %s with bd_block_size %u dev_id (%x:%x:%x:%x)\n",
__func__,
bd->bd_disk->disk_name,
- bd->bd_block_size);
+ bd->bd_block_size,
+ ((unsigned *)rv->bm_mdevid.data)[0], ((unsigned *)rv->bm_mdevid.data)[1],
+ ((unsigned *)rv->bm_mdevid.data)[2], ((unsigned *)rv->bm_mdevid.data)[3]);
out:
kfree(msg.data);
@@ -199,7 +203,9 @@ struct pnfs_block_dev *
struct block_mount_id *mid;
struct pnfs_block_dev *dev;
- dprintk("%s enter, lo=%p, id=%p\n", __func__, lo, id);
+ dprintk("%s enter, lo=%p, id=%p dev_id=(%x:%x:%x:%x)\n", __func__, lo, id,
+ ((unsigned *)id->data)[0], ((unsigned *)id->data)[1],
+ ((unsigned *)id->data)[2], ((unsigned *)id->data)[3]);
mid = BLK_ID(lo);
spin_lock(&mid->bm_lock);
list_for_each_entry(dev, &mid->bm_devlist, bm_node) {
--
1.7.6
On 2011-12-06 13:56, J. Bruce Fields wrote:
> On Tue, Dec 06, 2011 at 01:27:53PM +0200, Benny Halevy wrote:
>> On 2011-12-06 04:10, J. Bruce Fields wrote:
>>> On Sun, Dec 04, 2011 at 03:48:16PM +0200, Benny Halevy wrote:
>>>> From: Benny Halevy <[email protected]>
>>>>
>>>> Signed-off-by: Benny Halevy <[email protected]>
>>>> ---
>>>> fs/nfsd/bl_ops.c | 2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
>>>> index 89249c4..4d2939e 100644
>>>> --- a/fs/nfsd/bl_ops.c
>>>> +++ b/fs/nfsd/bl_ops.c
>>>> @@ -57,7 +57,7 @@
>>>> #endif
>>>>
>>>>
>>>> -typedef enum {True, False} boolean_t;
>>>> +typedef enum {False = 0, True = !False} boolean_t;
>>>
>>> Shouldn't we just use "bool"?
>>
>> Yes, in some cases. In others, the boolean status doesn't make sense
>> and I'd like to replace it with an integer.
>
> I believe casts from bools to integers are defined to convert false and
> true to 0 and 1 respectively, so you should be fine.
True, but in several cases like layout_cache_fill_from* or extents_get
a single status bit hides errors I'd rather percolate up the stack.
I'm not diving into this right now because this code needs a overhaul
to allow memory allocation outside the lock.
I'm thinking of a dual pass implementation, doing a pass under the lock
to calculate how many items to allocate. Doing the allocation after
releasing the (now mutex but better be spin) lock, and then running
through the list again under lock using the allocated memory.
The hard parts in this scheme are if the state of the layout changes and
we need more memory in the second pass. In this case we'll need yet another
iteration for the remainder, rinse, wash, repeat.
Benny
>
> --b.
> --
> 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
On Sun, Dec 04, 2011 at 03:48:28PM +0200, Benny Halevy wrote:
> From: Benny Halevy <[email protected]>
>
> Signed-off-by: Benny Halevy <[email protected]>
> ---
> fs/nfsd/bl_com.c | 2 +-
> fs/nfsd/bl_ops.c | 2 +-
> fs/nfsd/export.c | 2 +-
> fs/nfsd/nfs4proc.c | 2 +-
> fs/nfsd/nfs4xdr.c | 2 +-
> fs/nfsd/vfs.c | 2 +-
> include/linux/{ => nfsd}/nfsd4_block.h | 0
> 7 files changed, 6 insertions(+), 6 deletions(-)
> rename include/linux/{ => nfsd}/nfsd4_block.h (100%)
As long as this is only used in fs/nfsd, let's put this header file
in fs/nfsd.
--b.
>
> diff --git a/fs/nfsd/bl_com.c b/fs/nfsd/bl_com.c
> index cf37814..388d71a 100644
> --- a/fs/nfsd/bl_com.c
> +++ b/fs/nfsd/bl_com.c
> @@ -19,7 +19,7 @@
> #include <linux/nfs_fs.h>
>
> #include <linux/nfsd/debug.h>
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
>
> #define NFSDDBG_FACILITY NFSDDBG_PNFS
>
> diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
> index 4d2939e..15d2604 100644
> --- a/fs/nfsd/bl_ops.c
> +++ b/fs/nfsd/bl_ops.c
> @@ -28,7 +28,7 @@
> #include <linux/dm-ioctl.h>
> #include <asm/uaccess.h>
> #include <linux/falloc.h>
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
>
> #include "pnfsd.h"
>
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index 10a05de..9585795 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -19,7 +19,7 @@
> #if defined(CONFIG_SPNFS)
> #include <linux/nfsd4_spnfs.h>
> #if defined(CONFIG_SPNFS_BLOCK)
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
> #endif
> #endif
> #include <net/ipv6.h>
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index e4745ca..501781d 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -36,7 +36,7 @@
> #include <linux/slab.h>
> #include <linux/nfsd/nfs4layoutxdr.h>
> #include <linux/nfsd4_spnfs.h>
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
>
> #include "idmap.h"
> #include "cache.h"
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index bd8e693..cebd5a2 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -49,7 +49,7 @@
> #include <linux/exportfs.h>
> #include <linux/nfsd/nfs4layoutxdr.h>
> #include <linux/nfsd4_spnfs.h>
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
>
> #include "idmap.h"
> #include "acl.h"
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 43efbdc..ce07f67 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -40,7 +40,7 @@
> #include <linux/nfsd4_spnfs.h>
> #endif /* CONFIG_NFSD_V4 */
> #if defined(CONFIG_SPNFS_BLOCK)
> -#include <linux/nfsd4_block.h>
> +#include <linux/nfsd/nfsd4_block.h>
> #endif
>
> #include "nfsd.h"
> diff --git a/include/linux/nfsd4_block.h b/include/linux/nfsd/nfsd4_block.h
> similarity index 100%
> rename from include/linux/nfsd4_block.h
> rename to include/linux/nfsd/nfsd4_block.h
> --
> 1.7.6
>
> --
> 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
From: Benny Halevy <[email protected]>
Signed-off-by: Benny Halevy <[email protected]>
---
fs/nfsd/bl_ops.c | 34 ++++++++++++++++++----------------
fs/nfsd/nfs4pnfsd.c | 28 +++++++++++++++++++++++++---
fs/nfsd/pnfsd.h | 1 +
3 files changed, 44 insertions(+), 19 deletions(-)
diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index f5980a3..04788a1 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -95,7 +95,7 @@
dev_t devid, int my_loc, int idx);
static int layout_cache_fill_from(bl_layout_rec_t *r, struct list_head *h,
struct nfsd4_layout_seg *seg);
-struct list_head *layout_cache_iter(bl_layout_rec_t *r,
+struct list_head *layout_cache_iter(struct super_block *, bl_layout_rec_t *r,
struct list_head *bl_possible, struct nfsd4_layout_seg *seg);
static void layout_cache_merge(bl_layout_rec_t *r, struct list_head *h);
static int layout_cache_update(bl_layout_rec_t *r, struct list_head *h);
@@ -117,8 +117,8 @@ static void extents_count(struct fiemap_extent_info *fei, struct inode *i,
static boolean_t extents_get(struct fiemap_extent_info *fei, struct inode *i,
u64 foff, u64 len);
static boolean_t extents_process(struct fiemap_extent_info *fei,
- struct list_head *bl_candidates, struct nfsd4_layout_seg *, dev_t dev,
- pnfs_blocklayout_layout_t *b);
+ struct list_head *bl_candidates, struct nfsd4_layout_seg *,
+ u64 sbid, dev_t dev, pnfs_blocklayout_layout_t *b);
static void extents_cleanup(struct fiemap_extent_info *fei);
void
@@ -420,7 +420,7 @@ enum nfsstat4
res->lg_return_on_close = 1;
res->lg_seg.length = 0;
- bl_candidates = layout_cache_iter(r, &bl_possible, &res->lg_seg);
+ bl_candidates = layout_cache_iter(i->i_sb, r, &bl_possible, &res->lg_seg);
if (!bl_candidates) {
nfserr = NFS4ERR_LAYOUTTRYLATER;
goto layoutget_cleanup;
@@ -775,8 +775,8 @@ enum nfsstat4
}
struct list_head *
-layout_cache_iter(bl_layout_rec_t *r, struct list_head *bl_possible,
- struct nfsd4_layout_seg *seg)
+layout_cache_iter(struct super_block *sb, bl_layout_rec_t *r,
+ struct list_head *bl_possible, struct nfsd4_layout_seg *seg)
{
pnfs_blocklayout_layout_t *b,
*n = NULL;
@@ -784,6 +784,7 @@ struct list_head *
struct fiemap_extent_info fei;
struct inode *i;
dev_t dev;
+ u64 sbid = find_sbid(sb);
dev = r->blr_rdev;
i = r->blr_inode;
@@ -810,7 +811,7 @@ struct list_head *
b->bll_len) == False)
goto cleanup;
if (extents_process(&fei, bl_candidates,
- seg, dev, b) == False)
+ seg, sbid, dev, b) == False)
goto cleanup;
extents_cleanup(&fei);
@@ -825,7 +826,7 @@ struct list_head *
n = bll_alloc(b->bll_foff, b->bll_len,
BLOCK_LAYOUT_NEW, bl_candidates);
n->bll_es = PNFS_BLOCK_NONE_DATA;
- n->bll_vol_id.sbid = 0;
+ n->bll_vol_id.sbid = sbid;
n->bll_vol_id.devid = dev;
seg->length += b->bll_len;
} else {
@@ -1177,7 +1178,8 @@ struct list_head *
pnfs_blocklayout_layout_t *b,
*n;
enum pnfs_block_extent_state4 s;
-
+ u64 sbid = find_sbid(r->blr_inode->i_sb);
+
list_for_each_entry(b, &r->blr_layouts, bll_list) {
if (seg->offset < b->bll_foff) {
n = bll_alloc(seg->offset,
@@ -1218,7 +1220,7 @@ struct list_head *
return False;
n->bll_soff = b->bll_soff + seg->offset - b->bll_foff;
- n->bll_vol_id.sbid = 0;
+ n->bll_vol_id.sbid = sbid;
n->bll_vol_id.devid = b->bll_vol_id.devid;
n->bll_es = s;
seg->offset += n->bll_len;
@@ -1232,7 +1234,7 @@ struct list_head *
static u64
bll_alloc_holey(struct list_head *bl_candidates, u64 offset, u64 length,
- dev_t dev)
+ u64 sbid, dev_t dev)
{
pnfs_blocklayout_layout_t *n;
@@ -1240,7 +1242,7 @@ struct list_head *
if (!n)
return 0;
n->bll_es = PNFS_BLOCK_NONE_DATA;
- n->bll_vol_id.sbid = 0;
+ n->bll_vol_id.sbid = sbid;
n->bll_vol_id.devid = dev;
return n->bll_len;
@@ -1323,7 +1325,7 @@ struct list_head *
*/
static boolean_t
extents_process(struct fiemap_extent_info *fei, struct list_head *bl_candidates,
- struct nfsd4_layout_seg *seg, dev_t dev, pnfs_blocklayout_layout_t *b)
+ struct nfsd4_layout_seg *seg, u64 sbid, dev_t dev, pnfs_blocklayout_layout_t *b)
{
struct fiemap_extent *fep,
*fep_last = NULL;
@@ -1353,7 +1355,7 @@ struct list_head *
_2SECTS(fep_last->fe_length));
last_end = fep_last->fe_logical + fep_last->fe_length;
rval = bll_alloc_holey(bl_candidates, last_end,
- fep->fe_logical - last_end, dev);
+ fep->fe_logical - last_end, sbid, dev);
if (!rval)
return False;
seg->length += rval;
@@ -1369,7 +1371,7 @@ struct list_head *
n->bll_soff = fep->fe_physical;
n->bll_es = seg->iomode == IOMODE_READ ?
PNFS_BLOCK_READ_DATA : PNFS_BLOCK_READWRITE_DATA;
- n->bll_vol_id.sbid = 0;
+ n->bll_vol_id.sbid = sbid;
n->bll_vol_id.devid = dev;
seg->length += fep->fe_length;
print_bll(n, "New extent");
@@ -1638,7 +1640,7 @@ struct list_head *
if (n) {
n->bll_es = b->bll_es;
n->bll_soff = b->bll_soff;
- n->bll_vol_id.devid = b->bll_vol_id.devid;
+ n->bll_vol_id = b->bll_vol_id;
}
return n;
}
diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index 42e2bb0..6b2e327 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -416,15 +416,14 @@ struct super_block *
return sb;
}
-u64
-find_create_sbid(struct super_block *sb)
+static u64
+__find_sbid(struct super_block *sb)
{
struct sbid_tracker *sbid;
unsigned long hash_idx = sbid_hashval(sb);
int pos = 0;
u64 id = 0;
- spin_lock(&layout_lock);
list_for_each_entry (sbid, &sbid_hashtbl[hash_idx], hash) {
pos++;
if (sbid->sb != sb)
@@ -434,6 +433,29 @@ struct super_block *
id = sbid->id;
break;
}
+
+ return id;
+}
+
+u64
+find_sbid(struct super_block *sb)
+{
+ u64 id;
+
+ spin_lock(&layout_lock);
+ id = __find_sbid(sb);
+ spin_unlock(&layout_lock);
+
+ return id;
+}
+
+u64
+find_create_sbid(struct super_block *sb)
+{
+ u64 id;
+
+ spin_lock(&layout_lock);
+ id = __find_sbid(sb);
spin_unlock(&layout_lock);
if (!id)
diff --git a/fs/nfsd/pnfsd.h b/fs/nfsd/pnfsd.h
index f0862fb..abcb308 100644
--- a/fs/nfsd/pnfsd.h
+++ b/fs/nfsd/pnfsd.h
@@ -111,6 +111,7 @@ struct nfs4_notify_device {
struct nfsd4_callback nd_recall;
};
+u64 find_sbid(struct super_block *);
u64 find_create_sbid(struct super_block *);
struct super_block *find_sbid_id(u64);
__be32 nfs4_pnfs_get_layout(struct nfsd4_pnfs_layoutget *, struct exp_xdr_stream *);
--
1.7.6