From ef326407d56ad9a0af8cf60e4544ba5a88a37cfd Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Sat, 16 Jun 2012 15:16:55 +0800 Subject: [PATCH] LU-1513 libcfs: call cfs_alloc with proper masks Do not use kernel GFP masks directly when call cfs_alloc, instead, Lustre special flags can be used to control the allocator's behavior. cfs_alloc will convert these Lustre special flags to some kernle GFP masks, then call kmalloc with these GFP masks. Signed-off-by: Fan Yong Change-Id: I3189e143ff0cf65a08a1bdf2b8476ab151dc308e Reviewed-on: http://review.whamcloud.com/3118 Reviewed-by: Oleg Drokin Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger --- libcfs/include/libcfs/libcfs.h | 2 ++ libcfs/libcfs/winnt/winnt-proc.c | 4 ++-- libcfs/libcfs/winnt/winnt-tracefile.c | 4 ++-- lustre/llite/remote_perm.c | 10 +++++----- lustre/lvfs/lustre_quota_fmt.c | 2 +- lustre/obdfilter/filter.c | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libcfs/include/libcfs/libcfs.h b/libcfs/include/libcfs/libcfs.h index 5fbeed9..c231439 100644 --- a/libcfs/include/libcfs/libcfs.h +++ b/libcfs/include/libcfs/libcfs.h @@ -200,6 +200,8 @@ enum cfs_alloc_flags { /* standard allocator flag combination */ CFS_ALLOC_STD = CFS_ALLOC_FS | CFS_ALLOC_IO, CFS_ALLOC_USER = CFS_ALLOC_WAIT | CFS_ALLOC_FS | CFS_ALLOC_IO, + CFS_ALLOC_NOFS = CFS_ALLOC_WAIT | CFS_ALLOC_IO, + CFS_ALLOC_KERNEL = CFS_ALLOC_WAIT | CFS_ALLOC_IO | CFS_ALLOC_FS, }; /* flags for cfs_page_alloc() in addition to enum cfs_alloc_flags */ diff --git a/libcfs/libcfs/winnt/winnt-proc.c b/libcfs/libcfs/winnt/winnt-proc.c index 5c10c4f..6f46d09 100644 --- a/libcfs/libcfs/winnt/winnt-proc.c +++ b/libcfs/libcfs/winnt/winnt-proc.c @@ -2023,7 +2023,7 @@ static int traverse(struct seq_file *m, loff_t offset) Eoverflow: m->op->stop(m, p); cfs_free(m->buf); - m->buf = cfs_alloc(m->size <<= 1, GFP_KERNEL | CFS_ALLOC_ZERO); + m->buf = cfs_alloc(m->size <<= 1, CFS_ALLOC_KERNEL | CFS_ALLOC_ZERO); return !m->buf ? -ENOMEM : -EAGAIN; } @@ -2242,7 +2242,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops, void *private; struct seq_file *seq; - private = cfs_alloc(psize, GFP_KERNEL | CFS_ALLOC_ZERO); + private = cfs_alloc(psize, CFS_ALLOC_KERNEL | CFS_ALLOC_ZERO); if (private == NULL) goto out; diff --git a/libcfs/libcfs/winnt/winnt-tracefile.c b/libcfs/libcfs/winnt/winnt-tracefile.c index fd0e434..168c973 100644 --- a/libcfs/libcfs/winnt/winnt-tracefile.c +++ b/libcfs/libcfs/winnt/winnt-tracefile.c @@ -61,7 +61,7 @@ int cfs_tracefile_init_arch() for (i = 0; i < CFS_TCD_TYPE_MAX; i++) { cfs_trace_data[i] = cfs_alloc(sizeof(union cfs_trace_data_union) * \ - CFS_NR_CPUS, GFP_KERNEL); + CFS_NR_CPUS, CFS_ALLOC_KERNEL); if (cfs_trace_data[i] == NULL) goto out; } @@ -77,7 +77,7 @@ int cfs_tracefile_init_arch() for (j = 0; j < CFS_TCD_TYPE_MAX; j++) { cfs_trace_console_buffers[i][j] = cfs_alloc(CFS_TRACE_CONSOLE_BUFFER_SIZE, - GFP_KERNEL); + CFS_ALLOC_KERNEL); if (cfs_trace_console_buffers[i][j] == NULL) goto out; diff --git a/lustre/llite/remote_perm.c b/lustre/llite/remote_perm.c index 64dfd64..37471ae 100644 --- a/lustre/llite/remote_perm.c +++ b/lustre/llite/remote_perm.c @@ -60,12 +60,12 @@ cfs_mem_cache_t *ll_rmtperm_hash_cachep = NULL; static inline struct ll_remote_perm *alloc_ll_remote_perm(void) { - struct ll_remote_perm *lrp; + struct ll_remote_perm *lrp; - OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, GFP_KERNEL); - if (lrp) - CFS_INIT_HLIST_NODE(&lrp->lrp_list); - return lrp; + OBD_SLAB_ALLOC_PTR_GFP(lrp, ll_remote_perm_cachep, CFS_ALLOC_KERNEL); + if (lrp) + CFS_INIT_HLIST_NODE(&lrp->lrp_list); + return lrp; } static inline void free_ll_remote_perm(struct ll_remote_perm *lrp) diff --git a/lustre/lvfs/lustre_quota_fmt.c b/lustre/lvfs/lustre_quota_fmt.c index d7fafaa..82636c8 100644 --- a/lustre/lvfs/lustre_quota_fmt.c +++ b/lustre/lvfs/lustre_quota_fmt.c @@ -1098,7 +1098,7 @@ int lustre_get_qids(struct file *fp, struct inode *inode, int type, (char *)&ddquot[i], dqblk_sz)) continue; - OBD_ALLOC_GFP(dqid, sizeof(*dqid), GFP_NOFS); + OBD_ALLOC_GFP(dqid, sizeof(*dqid), CFS_ALLOC_NOFS); if (!dqid) GOTO(out_free, rc = -ENOMEM); diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 71aae20..c3ad008 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1921,7 +1921,7 @@ static int filter_iobuf_pool_init(struct filter_obd *filter) OBD_ALLOC_GFP(filter->fo_iobuf_pool, OSS_THREADS_MAX * sizeof(*pool), - GFP_KERNEL); + CFS_ALLOC_KERNEL); if (filter->fo_iobuf_pool == NULL) RETURN(-ENOMEM); -- 1.8.3.1