Merge commit 'refs/remotes/origin/linux-kernel-mem' into HEAD

This commit is contained in:
Brian Behlendorf 2009-06-26 14:35:14 -07:00
commit 7ad8b1fc82
9 changed files with 44 additions and 30 deletions

View File

@ -1,3 +1 @@
gcc-branch zfs-branch
fix-branch
feature-branch

17
.topmsg
View File

@ -1,19 +1,6 @@
From: Brian Behlendorf <behlendorf1@llnl.gov> From: Brian Behlendorf <behlendorf1@llnl.gov>
Subject: [PATCH] zfs branch Subject: [PATCH] linux kernel mem
Merged result of all changes which are relevant to both Solaris Required kmem/vmem changes
and Linux builds of the ZFS code. These are changes where there
is a reasonable chance they will be accepted upstream.
Additionally, since this is effectively the root of the linux
ZFS tree the core linux build system is added here. This
includes autogen.sh, configure.ac, m4 macros, some scripts/*,
and makefiles for all the core ZFS components. Linux-only
features which require tweaks to the build system should appear
on the relevant topic branches. All autotools products which
result from autogen.sh are commited to the linux-configure-branch.
This branch also contains the META, ChangeLog, AUTHORS, TODO,
and README, files.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>

View File

@ -303,6 +303,9 @@ extern void kstat_delete(kstat_t *);
#define kmem_alloc(_s, _f) umem_alloc(_s, _f) #define kmem_alloc(_s, _f) umem_alloc(_s, _f)
#define kmem_zalloc(_s, _f) umem_zalloc(_s, _f) #define kmem_zalloc(_s, _f) umem_zalloc(_s, _f)
#define kmem_free(_b, _s) umem_free(_b, _s) #define kmem_free(_b, _s) umem_free(_b, _s)
#define vmem_alloc(_s, _f) kmem_alloc(_s, _f)
#define vmem_zalloc(_s, _f) kmem_zalloc(_s, _f)
#define vmem_free(_b, _s) kmem_free(_b, _s)
#define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \ #define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \
umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i)
#define kmem_cache_destroy(_c) umem_cache_destroy(_c) #define kmem_cache_destroy(_c) umem_cache_destroy(_c)

View File

@ -755,8 +755,15 @@ buf_fini(void)
{ {
int i; int i;
#if defined(_KERNEL) && defined(HAVE_SPL)
/* Large allocations which do not require contiguous pages
* should be using vmem_free() in the linux kernel */
vmem_free(buf_hash_table.ht_table,
(buf_hash_table.ht_mask + 1) * sizeof (void *));
#else
kmem_free(buf_hash_table.ht_table, kmem_free(buf_hash_table.ht_table,
(buf_hash_table.ht_mask + 1) * sizeof (void *)); (buf_hash_table.ht_mask + 1) * sizeof (void *));
#endif
for (i = 0; i < BUF_LOCKS; i++) for (i = 0; i < BUF_LOCKS; i++)
mutex_destroy(&buf_hash_table.ht_locks[i].ht_lock); mutex_destroy(&buf_hash_table.ht_locks[i].ht_lock);
kmem_cache_destroy(hdr_cache); kmem_cache_destroy(hdr_cache);
@ -855,8 +862,15 @@ buf_init(void)
hsize <<= 1; hsize <<= 1;
retry: retry:
buf_hash_table.ht_mask = hsize - 1; buf_hash_table.ht_mask = hsize - 1;
#if defined(_KERNEL) && defined(HAVE_SPL)
/* Large allocations which do not require contiguous pages
* should be using vmem_alloc() in the linux kernel */
buf_hash_table.ht_table =
vmem_zalloc(hsize * sizeof (void*), KM_SLEEP);
#else
buf_hash_table.ht_table = buf_hash_table.ht_table =
kmem_zalloc(hsize * sizeof (void*), KM_NOSLEEP); kmem_zalloc(hsize * sizeof (void*), KM_NOSLEEP);
#endif
if (buf_hash_table.ht_table == NULL) { if (buf_hash_table.ht_table == NULL) {
ASSERT(hsize > (1ULL << 8)); ASSERT(hsize > (1ULL << 8));
hsize >>= 1; hsize >>= 1;

View File

@ -255,7 +255,13 @@ dbuf_init(void)
retry: retry:
h->hash_table_mask = hsize - 1; h->hash_table_mask = hsize - 1;
#if defined(_KERNEL) && defined(HAVE_SPL)
/* Large allocations which do not require contiguous pages
* should be using vmem_alloc() in the linux kernel */
h->hash_table = vmem_zalloc(hsize * sizeof (void *), KM_SLEEP);
#else
h->hash_table = kmem_zalloc(hsize * sizeof (void *), KM_NOSLEEP); h->hash_table = kmem_zalloc(hsize * sizeof (void *), KM_NOSLEEP);
#endif
if (h->hash_table == NULL) { if (h->hash_table == NULL) {
/* XXX - we should really return an error instead of assert */ /* XXX - we should really return an error instead of assert */
ASSERT(hsize > (1ULL << 10)); ASSERT(hsize > (1ULL << 10));
@ -279,7 +285,13 @@ dbuf_fini(void)
for (i = 0; i < DBUF_MUTEXES; i++) for (i = 0; i < DBUF_MUTEXES; i++)
mutex_destroy(&h->hash_mutexes[i]); mutex_destroy(&h->hash_mutexes[i]);
#if defined(_KERNEL) && defined(HAVE_SPL)
/* Large allocations which do not require contiguous pages
* should be using vmem_free() in the linux kernel */
vmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *));
#else
kmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *)); kmem_free(h->hash_table, (h->hash_table_mask + 1) * sizeof (void *));
#endif
kmem_cache_destroy(dbuf_cache); kmem_cache_destroy(dbuf_cache);
} }

View File

@ -1008,7 +1008,7 @@ dmu_recv_stream(dmu_recv_cookie_t *drc, vnode_t *vp, offset_t *voffp)
ra.vp = vp; ra.vp = vp;
ra.voff = *voffp; ra.voff = *voffp;
ra.bufsize = 1<<20; ra.bufsize = 1<<20;
ra.buf = kmem_alloc(ra.bufsize, KM_SLEEP); ra.buf = vmem_alloc(ra.bufsize, KM_SLEEP);
/* these were verified in dmu_recv_begin */ /* these were verified in dmu_recv_begin */
ASSERT(drc->drc_drrb->drr_version == DMU_BACKUP_STREAM_VERSION); ASSERT(drc->drc_drrb->drr_version == DMU_BACKUP_STREAM_VERSION);
@ -1098,7 +1098,7 @@ out:
dmu_recv_abort_cleanup(drc); dmu_recv_abort_cleanup(drc);
} }
kmem_free(ra.buf, ra.bufsize); vmem_free(ra.buf, ra.bufsize);
*voffp = ra.voff; *voffp = ra.voff;
return (ra.err); return (ra.err);
} }

View File

@ -281,7 +281,7 @@ spa_history_log_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx)
dmu_buf_rele(dbp, FTAG); dmu_buf_rele(dbp, FTAG);
if (hap->ha_log_type == LOG_INTERNAL) { if (hap->ha_log_type == LOG_INTERNAL) {
kmem_free((void*)hap->ha_history_str, HIS_MAX_RECORD_LEN); vmem_free((void*)hap->ha_history_str, HIS_MAX_RECORD_LEN);
kmem_free(hap, sizeof (history_arg_t)); kmem_free(hap, sizeof (history_arg_t));
} }
} }
@ -407,7 +407,7 @@ spa_history_internal_log(history_internal_events_t event, spa_t *spa,
return; return;
hap = kmem_alloc(sizeof (history_arg_t), KM_SLEEP); hap = kmem_alloc(sizeof (history_arg_t), KM_SLEEP);
str = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP); str = vmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
va_start(adx, fmt); va_start(adx, fmt);
(void) vsnprintf(str, HIS_MAX_RECORD_LEN, fmt, adx); (void) vsnprintf(str, HIS_MAX_RECORD_LEN, fmt, adx);

View File

@ -49,7 +49,7 @@ txg_init(dsl_pool_t *dp, uint64_t txg)
int c; int c;
bzero(tx, sizeof (tx_state_t)); bzero(tx, sizeof (tx_state_t));
tx->tx_cpu = kmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP); tx->tx_cpu = vmem_zalloc(max_ncpus * sizeof (tx_cpu_t), KM_SLEEP);
for (c = 0; c < max_ncpus; c++) { for (c = 0; c < max_ncpus; c++) {
int i; int i;
@ -109,7 +109,7 @@ txg_fini(dsl_pool_t *dp)
if (tx->tx_commit_cb_taskq != NULL) if (tx->tx_commit_cb_taskq != NULL)
taskq_destroy(tx->tx_commit_cb_taskq); taskq_destroy(tx->tx_commit_cb_taskq);
kmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t)); vmem_free(tx->tx_cpu, max_ncpus * sizeof (tx_cpu_t));
bzero(tx, sizeof (tx_state_t)); bzero(tx, sizeof (tx_state_t));
} }

View File

@ -134,7 +134,7 @@ __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
static void static void
history_str_free(char *buf) history_str_free(char *buf)
{ {
kmem_free(buf, HIS_MAX_RECORD_LEN); vmem_free(buf, HIS_MAX_RECORD_LEN);
} }
static char * static char *
@ -145,7 +145,7 @@ history_str_get(zfs_cmd_t *zc)
if (zc->zc_history == 0) if (zc->zc_history == 0)
return (NULL); return (NULL);
buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP); buf = vmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP);
if (copyinstr((void *)(uintptr_t)zc->zc_history, if (copyinstr((void *)(uintptr_t)zc->zc_history,
buf, HIS_MAX_RECORD_LEN, NULL) != 0) { buf, HIS_MAX_RECORD_LEN, NULL) != 0) {
history_str_free(buf); history_str_free(buf);
@ -729,12 +729,12 @@ put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
if (size > zc->zc_nvlist_dst_size) { if (size > zc->zc_nvlist_dst_size) {
error = ENOMEM; error = ENOMEM;
} else { } else {
packed = kmem_alloc(size, KM_SLEEP); packed = vmem_alloc(size, KM_SLEEP);
VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE, VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
KM_SLEEP) == 0); KM_SLEEP) == 0);
error = xcopyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst, error = xcopyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst,
size); size);
kmem_free(packed, size); vmem_free(packed, size);
} }
zc->zc_nvlist_dst_size = size; zc->zc_nvlist_dst_size = size;
@ -3002,7 +3002,7 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0])) if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
return (EINVAL); return (EINVAL);
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); zc = vmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
error = xcopyin((void *)arg, zc, sizeof (zfs_cmd_t)); error = xcopyin((void *)arg, zc, sizeof (zfs_cmd_t));
@ -3041,7 +3041,7 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
zfs_log_history(zc); zfs_log_history(zc);
} }
kmem_free(zc, sizeof (zfs_cmd_t)); vmem_free(zc, sizeof (zfs_cmd_t));
return (error); return (error);
} }