Whamcloud - gitweb
LU-1513 libcfs: call cfs_alloc with proper masks
authorFan Yong <yong.fan@whamcloud.com>
Sat, 16 Jun 2012 07:16:55 +0000 (15:16 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 16 Jun 2012 21:38:23 +0000 (17:38 -0400)
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 <yong.fan@whamcloud.com>
Change-Id: I3189e143ff0cf65a08a1bdf2b8476ab151dc308e
Reviewed-on: http://review.whamcloud.com/3118
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
libcfs/include/libcfs/libcfs.h
libcfs/libcfs/winnt/winnt-proc.c
libcfs/libcfs/winnt/winnt-tracefile.c
lustre/llite/remote_perm.c
lustre/lvfs/lustre_quota_fmt.c
lustre/obdfilter/filter.c

index 5fbeed9..c231439 100644 (file)
@@ -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 */
index 5c10c4f..6f46d09 100644 (file)
@@ -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;
 
index fd0e434..168c973 100644 (file)
@@ -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;
index 64dfd64..37471ae 100644 (file)
@@ -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)
index d7fafaa..82636c8 100644 (file)
@@ -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);
 
index 71aae20..c3ad008 100644 (file)
@@ -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);