From 6cf7f7c9dfcec0cac9ca11dc714f973e06fc057a Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:38:56 -0700 Subject: [PATCH 1/8] Add fix-current topic branch In the linux kernel 'current' is defined to mean the current process and can never be used as a local variable in a function. Simply replace all usage of 'current' with 'curr' in this function. --- .topdeps | 1 + .topmsg | 8 ++++++++ module/zfs/vdev_raidz.c | 28 ++++++++++++++-------------- 3 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..770d17daf6 --- /dev/null +++ b/.topmsg @@ -0,0 +1,8 @@ +From: Brian Behlendorf +Subject: [PATCH] fix-current + +In the linux kernel 'current' is defined to mean the current process +and can never be used as a local variable in a function. Simply +replace all usage of 'current' with 'curr' in this function. + +Signed-off-by: Brian Behlendorf diff --git a/module/zfs/vdev_raidz.c b/module/zfs/vdev_raidz.c index 4b0f5602c1..700ce2e23d 100644 --- a/module/zfs/vdev_raidz.c +++ b/module/zfs/vdev_raidz.c @@ -1716,7 +1716,7 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) void *orig[VDEV_RAIDZ_MAXPARITY]; int tstore[VDEV_RAIDZ_MAXPARITY + 2]; int *tgts = &tstore[1]; - int current, next, i, c, n; + int curr, next, i, c, n; int code, ret = 0; ASSERT(total_errors < rm->rm_firstdatacol); @@ -1764,12 +1764,12 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) orig[n - 1] = zio_buf_alloc(rm->rm_col[0].rc_size); - current = 0; - next = tgts[current]; + curr = 0; + next = tgts[curr]; - while (current != n) { - tgts[current] = next; - current = 0; + while (curr != n) { + tgts[curr] = next; + curr = 0; /* * Save off the original data that we're going to @@ -1817,34 +1817,34 @@ vdev_raidz_combrec(zio_t *zio, int total_errors, int data_errors) do { /* - * Find the next valid column after the current + * Find the next valid column after the curr * position.. */ - for (next = tgts[current] + 1; + for (next = tgts[curr] + 1; next < rm->rm_cols && rm->rm_col[next].rc_error != 0; next++) continue; - ASSERT(next <= tgts[current + 1]); + ASSERT(next <= tgts[curr + 1]); /* * If that spot is available, we're done here. */ - if (next != tgts[current + 1]) + if (next != tgts[curr + 1]) break; /* * Otherwise, find the next valid column after * the previous position. */ - for (c = tgts[current - 1] + 1; + for (c = tgts[curr - 1] + 1; rm->rm_col[c].rc_error != 0; c++) continue; - tgts[current] = c; - current++; + tgts[curr] = c; + curr++; - } while (current != n); + } while (curr != n); } } n--; From 7a73e518321973743de76ef523db66a6d54f981d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:39:25 -0700 Subject: [PATCH 2/8] New TopGit dependency: fix-current --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index 9f596a1feb..67e8776a68 100644 --- a/.topdeps +++ b/.topdeps @@ -12,3 +12,4 @@ fix-deadcode fix-acl fix-error-handling fix-pthreads +fix-current From f3a61f709da46ddab993b55c197b09950f7a92b5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:40:26 -0700 Subject: [PATCH 3/8] Add fix-metaslab topic branch If your only going to allow one allocator to be used and it is defined at compile time there is no point including the others in the build. This patch could/should be refined for Linux to make the metaslab configurable at run time. That might be a bit tricky however since you would need to quiese all IO. Short of that making it configurable as a module load option would be a reasonable compromise. --- .topdeps | 1 + .topmsg | 11 +++++++++++ module/zfs/metaslab.c | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..4fc1ff1482 --- /dev/null +++ b/.topmsg @@ -0,0 +1,11 @@ +From: Brian Behlendorf +Subject: [PATCH] fix metaslab + +If your only going to allow one allocator to be used and it is defined +at compile time there is no point including the others in the build. +This patch could/should be refined for Linux to make the metaslab +configurable at run time. That might be a bit tricky however since +you would need to quiese all IO. Short of that making it configurable +as a module load option would be a reasonable compromise. + +Signed-off-by: Brian Behlendorf diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index 17b4b12c4e..3d5353fedf 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -30,6 +30,8 @@ #include #include +#define WITH_NDF_BLOCK_ALLOCATOR + uint64_t metaslab_aliquot = 512ULL << 10; uint64_t metaslab_gang_bang = SPA_MAXBLOCKSIZE + 1; /* force gang blocks */ @@ -350,6 +352,9 @@ metaslab_segsize_compare(const void *x1, const void *x2) return (0); } +#if defined(WITH_FF_BLOCK_ALLOCATOR) || \ + defined(WITH_DF_BLOCK_ALLOCATOR) || \ + defined(WITH_CDF_BLOCK_ALLOCATOR) /* * This is a helper function that can be used by the allocator to find * a suitable block to allocate. This will search the specified AVL @@ -389,6 +394,7 @@ metaslab_block_picker(avl_tree_t *t, uint64_t *cursor, uint64_t size, *cursor = 0; return (metaslab_block_picker(t, cursor, size, align)); } +#endif /* WITH_FF/DF/CDF_BLOCK_ALLOCATOR */ static void metaslab_pp_load(space_map_t *sm) @@ -452,6 +458,7 @@ metaslab_pp_maxsize(space_map_t *sm) return (ss->ss_end - ss->ss_start); } +#if defined(WITH_FF_BLOCK_ALLOCATOR) /* * ========================================================================== * The first-fit block allocator @@ -484,6 +491,10 @@ static space_map_ops_t metaslab_ff_ops = { metaslab_ff_fragmented }; +space_map_ops_t *zfs_metaslab_ops = &metaslab_ff_ops; +#endif /* WITH_FF_BLOCK_ALLOCATOR */ + +#if defined(WITH_DF_BLOCK_ALLOCATOR) /* * ========================================================================== * Dynamic block allocator - @@ -543,11 +554,15 @@ static space_map_ops_t metaslab_df_ops = { metaslab_df_fragmented }; +space_map_ops_t *zfs_metaslab_ops = &metaslab_df_ops; +#endif /* WITH_DF_BLOCK_ALLOCATOR */ + /* * ========================================================================== * Other experimental allocators * ========================================================================== */ +#if defined(WITH_CDF_BLOCK_ALLOCATOR) static uint64_t metaslab_cdf_alloc(space_map_t *sm, uint64_t size) { @@ -607,6 +622,10 @@ static space_map_ops_t metaslab_cdf_ops = { metaslab_cdf_fragmented }; +space_map_ops_t *zfs_metaslab_ops = &metaslab_cdf_ops; +#endif /* WITH_CDF_BLOCK_ALLOCATOR */ + +#if defined(WITH_NDF_BLOCK_ALLOCATOR) uint64_t metaslab_ndf_clump_shift = 4; static uint64_t @@ -672,6 +691,7 @@ static space_map_ops_t metaslab_ndf_ops = { }; space_map_ops_t *zfs_metaslab_ops = &metaslab_ndf_ops; +#endif /* WITH_NDF_BLOCK_ALLOCATOR */ /* * ========================================================================== From 9519cc9a54f7bdd16438d6b33121098ed6b494e5 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:40:43 -0700 Subject: [PATCH 4/8] New TopGit dependency: fix-metaslab --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index 67e8776a68..cb9e2a24a9 100644 --- a/.topdeps +++ b/.topdeps @@ -13,3 +13,4 @@ fix-acl fix-error-handling fix-pthreads fix-current +fix-metaslab From f61a7ce9e1c7edb2c6547b80d27d093a9c8ae7a6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:43:01 -0700 Subject: [PATCH 5/8] Add fix-kstat-xuio topic branch Move xiou stat structures from a header to the dmu.c source as is done with all the other kstat interfaces. This information is local to dmu.c registered the xuio kstat and should stay that way. --- .topdeps | 1 + .topmsg | 8 ++++++++ module/zfs/dmu.c | 25 +++++++++++++++++++++++++ module/zfs/include/sys/dmu.h | 1 + module/zfs/include/sys/dmu_impl.h | 26 -------------------------- 5 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..b10884cb95 --- /dev/null +++ b/.topmsg @@ -0,0 +1,8 @@ +From: Brian Behlendorf +Subject: [PATCH] fix kstat xuio + +Move xiou stat structures from a header to the dmu.c source as is +done with all the other kstat interfaces. This information is local +to dmu.c registered the xuio kstat and should stay that way. + +Signed-off-by: Brian Behlendorf diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index 5b87c81c63..7ea00cf997 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -765,6 +765,31 @@ dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, */ kstat_t *xuio_ksp = NULL; +typedef struct xuio_stats { + /* loaned yet not returned arc_buf */ + kstat_named_t xuiostat_onloan_rbuf; + kstat_named_t xuiostat_onloan_wbuf; + /* whether a copy is made when loaning out a read buffer */ + kstat_named_t xuiostat_rbuf_copied; + kstat_named_t xuiostat_rbuf_nocopy; + /* whether a copy is made when assigning a write buffer */ + kstat_named_t xuiostat_wbuf_copied; + kstat_named_t xuiostat_wbuf_nocopy; +} xuio_stats_t; + +static xuio_stats_t xuio_stats = { + { "onloan_read_buf", KSTAT_DATA_UINT64 }, + { "onloan_write_buf", KSTAT_DATA_UINT64 }, + { "read_buf_copied", KSTAT_DATA_UINT64 }, + { "read_buf_nocopy", KSTAT_DATA_UINT64 }, + { "write_buf_copied", KSTAT_DATA_UINT64 }, + { "write_buf_nocopy", KSTAT_DATA_UINT64 } +}; + +#define XUIOSTAT_INCR(stat, val) \ + atomic_add_64(&xuio_stats.stat.value.ui64, (val)) +#define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1) + int dmu_xuio_init(xuio_t *xuio, int nblk) { diff --git a/module/zfs/include/sys/dmu.h b/module/zfs/include/sys/dmu.h index 83932f467a..496321aacb 100644 --- a/module/zfs/include/sys/dmu.h +++ b/module/zfs/include/sys/dmu.h @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/module/zfs/include/sys/dmu_impl.h b/module/zfs/include/sys/dmu_impl.h index 22f9f5f8c8..0b8748df10 100644 --- a/module/zfs/include/sys/dmu_impl.h +++ b/module/zfs/include/sys/dmu_impl.h @@ -239,32 +239,6 @@ typedef struct dmu_xuio { iovec_t *iovp; } dmu_xuio_t; -typedef struct xuio_stats { - /* loaned yet not returned arc_buf */ - kstat_named_t xuiostat_onloan_rbuf; - kstat_named_t xuiostat_onloan_wbuf; - /* whether a copy is made when loaning out a read buffer */ - kstat_named_t xuiostat_rbuf_copied; - kstat_named_t xuiostat_rbuf_nocopy; - /* whether a copy is made when assigning a write buffer */ - kstat_named_t xuiostat_wbuf_copied; - kstat_named_t xuiostat_wbuf_nocopy; -} xuio_stats_t; - -static xuio_stats_t xuio_stats = { - { "onloan_read_buf", KSTAT_DATA_UINT64 }, - { "onloan_write_buf", KSTAT_DATA_UINT64 }, - { "read_buf_copied", KSTAT_DATA_UINT64 }, - { "read_buf_nocopy", KSTAT_DATA_UINT64 }, - { "write_buf_copied", KSTAT_DATA_UINT64 }, - { "write_buf_nocopy", KSTAT_DATA_UINT64 } -}; - -#define XUIOSTAT_INCR(stat, val) \ - atomic_add_64(&xuio_stats.stat.value.ui64, (val)) -#define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1) - - #ifdef __cplusplus } #endif From f70976285e60113fb89b063a132df4049ce2ff94 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:43:30 -0700 Subject: [PATCH 6/8] New TopGit dependency: fix-kstat-xuio --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index cb9e2a24a9..f2408cb21c 100644 --- a/.topdeps +++ b/.topdeps @@ -14,3 +14,4 @@ fix-error-handling fix-pthreads fix-current fix-metaslab +fix-kstat-xuio From b8cc785fb63ce642a8b0ea615bc3b0c29189b520 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:45:01 -0700 Subject: [PATCH 7/8] Add fix-stack-lzjb topic branch Reduce kernel stack usage by lzjb_compress() by moving uint16 array off the stack and on to the heap. The exact performance implications of this I have not measured but we absolutely need to keep stack usage to a minimum. If/when this becomes and issue we optimize. --- .topdeps | 1 + .topmsg | 9 +++++++++ module/zfs/lzjb.c | 11 ++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 .topdeps create mode 100644 .topmsg diff --git a/.topdeps b/.topdeps new file mode 100644 index 0000000000..1f7391f92b --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 0000000000..4f1c8f2635 --- /dev/null +++ b/.topmsg @@ -0,0 +1,9 @@ +From: Brian Behlendorf +Subject: [PATCH] fix stack lzjb + +Reduce kernel stack usage by lzjb_compress() by moving uint16 array +off the stack and on to the heap. The exact performance implications +of this I have not measured but we absolutely need to keep stack +usage to a minimum. If/when this becomes and issue we optimize. + +Signed-off-by: Brian Behlendorf diff --git a/module/zfs/lzjb.c b/module/zfs/lzjb.c index 10952f472b..1f2deb51a0 100644 --- a/module/zfs/lzjb.c +++ b/module/zfs/lzjb.c @@ -37,7 +37,7 @@ * compress to d_len or less. */ -#include +#include #define MATCH_BITS 6 #define MATCH_MIN 3 @@ -55,12 +55,15 @@ lzjb_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) int copymask = 1 << (NBBY - 1); int mlen, offset, hash; uint16_t *hp; - uint16_t lempel[LEMPEL_SIZE] = { 0 }; + uint16_t *lempel; + lempel = kmem_zalloc(LEMPEL_SIZE * sizeof (uint16_t), KM_SLEEP); while (src < (uchar_t *)s_start + s_len) { if ((copymask <<= 1) == (1 << NBBY)) { - if (dst >= (uchar_t *)d_start + d_len - 1 - 2 * NBBY) + if (dst >= (uchar_t *)d_start + d_len - 1 - 2 * NBBY) { + kmem_free(lempel, LEMPEL_SIZE*sizeof(uint16_t)); return (s_len); + } copymask = 1; copymap = dst; *dst++ = 0; @@ -90,6 +93,8 @@ lzjb_compress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) *dst++ = *src++; } } + + kmem_free(lempel, LEMPEL_SIZE * sizeof (uint16_t)); return (dst - (uchar_t *)d_start); } From 4327d5dce32e157f214725ec1e925ed7210ea575 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 14 Jun 2010 16:45:31 -0700 Subject: [PATCH 8/8] New TopGit dependency: fix-stack-lzjb --- .topdeps | 1 + 1 file changed, 1 insertion(+) diff --git a/.topdeps b/.topdeps index f2408cb21c..675463cb74 100644 --- a/.topdeps +++ b/.topdeps @@ -15,3 +15,4 @@ fix-pthreads fix-current fix-metaslab fix-kstat-xuio +fix-stack-lzjb