Commit 496a51bd authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: llite: Use kzalloc and rewrite null tests

This patch removes some kzalloc-related macros and rewrites the
associated null tests to use !x rather than x == NULL.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression ptr;
statement S,S1;
@@

  \(OBD_ALLOC\|OBD_ALLOC_WAIT\|OBD_ALLOC_PTR\|OBD_ALLOC_PTR_WAIT\)(ptr,...);
  if (
+     !
      ptr
-      == NULL
     ) S else S1

@@
expression ptr,size;
@@

- OBD_ALLOC(ptr,size)
+ ptr = kzalloc(size, GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_ALLOC_WAIT(ptr,size)
+ ptr = kzalloc(size, GFP_KERNEL)

@@
expression ptr,size;
@@

- OBD_ALLOC_PTR(ptr)
+ ptr = kzalloc(sizeof(*ptr), GFP_NOFS)

@@
expression ptr,size;
@@

- OBD_ALLOC_PTR_WAIT(ptr,size)
+ ptr = kzalloc(sizeof(*ptr), GFP_KERNEL)
// </smpl>
Signed-off-by: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cdbcd330
...@@ -187,8 +187,8 @@ int ll_d_init(struct dentry *de) ...@@ -187,8 +187,8 @@ int ll_d_init(struct dentry *de)
if (de->d_fsdata == NULL) { if (de->d_fsdata == NULL) {
struct ll_dentry_data *lld; struct ll_dentry_data *lld;
OBD_ALLOC_PTR(lld); lld = kzalloc(sizeof(*lld), GFP_NOFS);
if (likely(lld != NULL)) { if (likely(lld)) {
spin_lock(&de->d_lock); spin_lock(&de->d_lock);
if (likely(de->d_fsdata == NULL)) { if (likely(de->d_fsdata == NULL)) {
de->d_fsdata = lld; de->d_fsdata = lld;
......
...@@ -163,8 +163,8 @@ static int ll_dir_filler(void *_hash, struct page *page0) ...@@ -163,8 +163,8 @@ static int ll_dir_filler(void *_hash, struct page *page0)
LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES); LASSERT(max_pages > 0 && max_pages <= MD_MAX_BRW_PAGES);
OBD_ALLOC(page_pool, sizeof(page) * max_pages); page_pool = kzalloc(sizeof(page) * max_pages, GFP_NOFS);
if (page_pool != NULL) { if (page_pool) {
page_pool[0] = page0; page_pool[0] = page0;
} else { } else {
page_pool = &page0; page_pool = &page0;
...@@ -638,7 +638,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string) ...@@ -638,7 +638,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string)
struct mgs_send_param *msp; struct mgs_send_param *msp;
int rc = 0; int rc = 0;
OBD_ALLOC_PTR(msp); msp = kzalloc(sizeof(*msp), GFP_NOFS);
if (!msp) if (!msp)
return -ENOMEM; return -ENOMEM;
...@@ -751,8 +751,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, ...@@ -751,8 +751,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
char *param = NULL; char *param = NULL;
char *buf; char *buf;
OBD_ALLOC(param, MGS_PARAM_MAXLEN); param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS);
if (param == NULL) { if (!param) {
rc = -ENOMEM; rc = -ENOMEM;
goto end; goto end;
} }
...@@ -1061,8 +1061,8 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp, ...@@ -1061,8 +1061,8 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
void *copy; void *copy;
int rc; int rc;
OBD_ALLOC(copy, size); copy = kzalloc(size, GFP_NOFS);
if (copy == NULL) if (!copy)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(copy, data, size)) { if (copy_from_user(copy, data, size)) {
...@@ -1152,8 +1152,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) ...@@ -1152,8 +1152,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
} else { } else {
struct obd_quotactl *oqctl; struct obd_quotactl *oqctl;
OBD_ALLOC_PTR(oqctl); oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (oqctl == NULL) if (!oqctl)
return -ENOMEM; return -ENOMEM;
QCTL_COPY(oqctl, qctl); QCTL_COPY(oqctl, qctl);
...@@ -1173,8 +1173,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) ...@@ -1173,8 +1173,8 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
!oqctl->qc_dqblk.dqb_curspace) { !oqctl->qc_dqblk.dqb_curspace) {
struct obd_quotactl *oqctl_tmp; struct obd_quotactl *oqctl_tmp;
OBD_ALLOC_PTR(oqctl_tmp); oqctl_tmp = kzalloc(sizeof(*oqctl_tmp), GFP_NOFS);
if (oqctl_tmp == NULL) { if (!oqctl_tmp) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -1412,8 +1412,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1412,8 +1412,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -EINVAL; return -EINVAL;
lum_size = lmv_user_md_size(1, LMV_MAGIC_V1); lum_size = lmv_user_md_size(1, LMV_MAGIC_V1);
OBD_ALLOC(tmp, lum_size); tmp = kzalloc(lum_size, GFP_NOFS);
if (tmp == NULL) { if (!tmp) {
rc = -ENOMEM; rc = -ENOMEM;
goto free_lmv; goto free_lmv;
} }
...@@ -1643,7 +1643,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1643,7 +1643,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
sbi->ll_flags & LL_SBI_RMT_CLIENT) sbi->ll_flags & LL_SBI_RMT_CLIENT)
return -EPERM; return -EPERM;
OBD_ALLOC_PTR(oqctl); oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl) if (!oqctl)
return -ENOMEM; return -ENOMEM;
oqctl->qc_type = arg; oqctl->qc_type = arg;
...@@ -1667,7 +1667,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1667,7 +1667,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
sbi->ll_flags & LL_SBI_RMT_CLIENT) sbi->ll_flags & LL_SBI_RMT_CLIENT)
return -EPERM; return -EPERM;
OBD_ALLOC_PTR(check); check = kzalloc(sizeof(*check), GFP_NOFS);
if (!check) if (!check)
return -ENOMEM; return -ENOMEM;
...@@ -1701,11 +1701,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1701,11 +1701,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct if_quotactl_18 *qctl_18; struct if_quotactl_18 *qctl_18;
struct if_quotactl *qctl_20; struct if_quotactl *qctl_20;
OBD_ALLOC_PTR(qctl_18); qctl_18 = kzalloc(sizeof(*qctl_18), GFP_NOFS);
if (!qctl_18) if (!qctl_18)
return -ENOMEM; return -ENOMEM;
OBD_ALLOC_PTR(qctl_20); qctl_20 = kzalloc(sizeof(*qctl_20), GFP_NOFS);
if (!qctl_20) { if (!qctl_20) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_quotactl_18; goto out_quotactl_18;
...@@ -1755,7 +1755,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1755,7 +1755,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case LL_IOC_QUOTACTL: { case LL_IOC_QUOTACTL: {
struct if_quotactl *qctl; struct if_quotactl *qctl;
OBD_ALLOC_PTR(qctl); qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
if (!qctl) if (!qctl)
return -ENOMEM; return -ENOMEM;
...@@ -1834,8 +1834,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1834,8 +1834,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_user_request *hur; struct hsm_user_request *hur;
ssize_t totalsize; ssize_t totalsize;
OBD_ALLOC_PTR(hur); hur = kzalloc(sizeof(*hur), GFP_NOFS);
if (hur == NULL) if (!hur)
return -ENOMEM; return -ENOMEM;
/* We don't know the true size yet; copy the fixed-size part */ /* We don't know the true size yet; copy the fixed-size part */
...@@ -1920,8 +1920,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1920,8 +1920,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
OBD_ALLOC_PTR(copy); copy = kzalloc(sizeof(*copy), GFP_NOFS);
if (copy == NULL) if (!copy)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
OBD_FREE_PTR(copy); OBD_FREE_PTR(copy);
...@@ -1939,8 +1939,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1939,8 +1939,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
OBD_ALLOC_PTR(copy); copy = kzalloc(sizeof(*copy), GFP_NOFS);
if (copy == NULL) if (!copy)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
OBD_FREE_PTR(copy); OBD_FREE_PTR(copy);
......
...@@ -146,8 +146,8 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, ...@@ -146,8 +146,8 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp,
goto out; goto out;
} }
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) { if (!op_data) {
/* XXX We leak openhandle and request here. */ /* XXX We leak openhandle and request here. */
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -659,7 +659,7 @@ int ll_file_open(struct inode *inode, struct file *file) ...@@ -659,7 +659,7 @@ int ll_file_open(struct inode *inode, struct file *file)
goto restart; goto restart;
} }
OBD_ALLOC(*och_p, sizeof (struct obd_client_handle)); *och_p = kzalloc(sizeof(struct obd_client_handle), GFP_NOFS);
if (!*och_p) { if (!*och_p) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_och_free; goto out_och_free;
...@@ -811,8 +811,8 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode, ...@@ -811,8 +811,8 @@ ll_lease_open(struct inode *inode, struct file *file, fmode_t fmode,
old_handle = fd->fd_och->och_fh; old_handle = fd->fd_och->och_fh;
} }
OBD_ALLOC_PTR(och); och = kzalloc(sizeof(*och), GFP_NOFS);
if (och == NULL) if (!och)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
op_data = ll_prep_md_op_data(NULL, inode, inode, NULL, 0, 0, op_data = ll_prep_md_op_data(NULL, inode, inode, NULL, 0, 0,
...@@ -1655,7 +1655,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) ...@@ -1655,7 +1655,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it)
LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0); LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0);
OBD_ALLOC(och, sizeof(*och)); och = kzalloc(sizeof(*och), GFP_NOFS);
if (!och) { if (!och) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -1759,8 +1759,8 @@ int ll_fid2path(struct inode *inode, void __user *arg) ...@@ -1759,8 +1759,8 @@ int ll_fid2path(struct inode *inode, void __user *arg)
outsize = sizeof(*gfout) + pathlen; outsize = sizeof(*gfout) + pathlen;
OBD_ALLOC(gfout, outsize); gfout = kzalloc(outsize, GFP_NOFS);
if (gfout == NULL) if (!gfout)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(gfout, arg, sizeof(*gfout))) { if (copy_from_user(gfout, arg, sizeof(*gfout))) {
...@@ -1867,8 +1867,8 @@ int ll_data_version(struct inode *inode, __u64 *data_version, ...@@ -1867,8 +1867,8 @@ int ll_data_version(struct inode *inode, __u64 *data_version,
goto out; goto out;
} }
OBD_ALLOC_PTR(obdo); obdo = kzalloc(sizeof(*obdo), GFP_NOFS);
if (obdo == NULL) { if (!obdo) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -1955,8 +1955,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, ...@@ -1955,8 +1955,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2,
struct ll_swap_stack *llss = NULL; struct ll_swap_stack *llss = NULL;
int rc; int rc;
OBD_ALLOC_PTR(llss); llss = kzalloc(sizeof(*llss), GFP_NOFS);
if (llss == NULL) if (!llss)
return -ENOMEM; return -ENOMEM;
llss->inode1 = file1->f_dentry->d_inode; llss->inode1 = file1->f_dentry->d_inode;
...@@ -2149,8 +2149,8 @@ static int ll_hsm_import(struct inode *inode, struct file *file, ...@@ -2149,8 +2149,8 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
return -EINVAL; return -EINVAL;
/* set HSM flags */ /* set HSM flags */
OBD_ALLOC_PTR(hss); hss = kzalloc(sizeof(*hss), GFP_NOFS);
if (hss == NULL) { if (!hss) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -2162,8 +2162,8 @@ static int ll_hsm_import(struct inode *inode, struct file *file, ...@@ -2162,8 +2162,8 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
if (rc != 0) if (rc != 0)
goto out; goto out;
OBD_ALLOC_PTR(attr); attr = kzalloc(sizeof(*attr), GFP_NOFS);
if (attr == NULL) { if (!attr) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -2341,8 +2341,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2341,8 +2341,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_user_state *hus; struct hsm_user_state *hus;
int rc; int rc;
OBD_ALLOC_PTR(hus); hus = kzalloc(sizeof(*hus), GFP_NOFS);
if (hus == NULL) if (!hus)
return -ENOMEM; return -ENOMEM;
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
...@@ -2366,8 +2366,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2366,8 +2366,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_state_set *hss; struct hsm_state_set *hss;
int rc; int rc;
OBD_ALLOC_PTR(hss); hss = kzalloc(sizeof(*hss), GFP_NOFS);
if (hss == NULL) if (!hss)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
...@@ -2385,8 +2385,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2385,8 +2385,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_current_action *hca; struct hsm_current_action *hca;
int rc; int rc;
OBD_ALLOC_PTR(hca); hca = kzalloc(sizeof(*hca), GFP_NOFS);
if (hca == NULL) if (!hca)
return -ENOMEM; return -ENOMEM;
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
...@@ -2493,8 +2493,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2493,8 +2493,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case LL_IOC_HSM_IMPORT: { case LL_IOC_HSM_IMPORT: {
struct hsm_user_import *hui; struct hsm_user_import *hui;
OBD_ALLOC_PTR(hui); hui = kzalloc(sizeof(*hui), GFP_NOFS);
if (hui == NULL) if (!hui)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(hui, (void *)arg, sizeof(*hui))) { if (copy_from_user(hui, (void *)arg, sizeof(*hui))) {
...@@ -3229,8 +3229,8 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) ...@@ -3229,8 +3229,8 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd)
return NULL; return NULL;
size = sizeof(*in_data) + count * sizeof(unsigned int); size = sizeof(*in_data) + count * sizeof(unsigned int);
OBD_ALLOC(in_data, size); in_data = kzalloc(size, GFP_NOFS);
if (in_data == NULL) if (!in_data)
return NULL; return NULL;
memset(in_data, 0, sizeof(*in_data)); memset(in_data, 0, sizeof(*in_data));
...@@ -3618,8 +3618,8 @@ int ll_layout_restore(struct inode *inode) ...@@ -3618,8 +3618,8 @@ int ll_layout_restore(struct inode *inode)
len = sizeof(struct hsm_user_request) + len = sizeof(struct hsm_user_request) +
sizeof(struct hsm_user_item); sizeof(struct hsm_user_item);
OBD_ALLOC(hur, len); hur = kzalloc(len, GFP_NOFS);
if (hur == NULL) if (!hur)
return -ENOMEM; return -ENOMEM;
hur->hur_request.hr_action = HUA_RESTORE; hur->hur_request.hr_action = HUA_RESTORE;
......
...@@ -285,8 +285,8 @@ static void ll_done_writing(struct inode *inode) ...@@ -285,8 +285,8 @@ static void ll_done_writing(struct inode *inode)
LASSERT(exp_connect_som(ll_i2mdexp(inode))); LASSERT(exp_connect_som(ll_i2mdexp(inode)));
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) { if (!op_data) {
CERROR("can't allocate op_data\n"); CERROR("can't allocate op_data\n");
return; return;
} }
...@@ -367,8 +367,8 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret) ...@@ -367,8 +367,8 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD)) if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD))
return -EINTR; return -EINTR;
OBD_ALLOC(lcq, sizeof(*lcq)); lcq = kzalloc(sizeof(*lcq), GFP_NOFS);
if (lcq == NULL) if (!lcq)
return -ENOMEM; return -ENOMEM;
spin_lock_init(&lcq->lcq_lock); spin_lock_init(&lcq->lcq_lock);
......
...@@ -75,7 +75,7 @@ static struct ll_sb_info *ll_init_sbi(void) ...@@ -75,7 +75,7 @@ static struct ll_sb_info *ll_init_sbi(void)
class_uuid_t uuid; class_uuid_t uuid;
int i; int i;
OBD_ALLOC(sbi, sizeof(*sbi)); sbi = kzalloc(sizeof(*sbi), GFP_NOFS);
if (!sbi) if (!sbi)
return NULL; return NULL;
...@@ -172,12 +172,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -172,12 +172,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
return -EINVAL; return -EINVAL;
} }
OBD_ALLOC_PTR(data); data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL) if (!data)
return -ENOMEM; return -ENOMEM;
OBD_ALLOC_PTR(osfs); osfs = kzalloc(sizeof(*osfs), GFP_NOFS);
if (osfs == NULL) { if (!osfs) {
OBD_FREE_PTR(data); OBD_FREE_PTR(data);
return -ENOMEM; return -ENOMEM;
} }
...@@ -293,7 +293,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -293,7 +293,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
valid != CLIENT_CONNECT_MDT_REQD) { valid != CLIENT_CONNECT_MDT_REQD) {
char *buf; char *buf;
OBD_ALLOC_WAIT(buf, PAGE_CACHE_SIZE); buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
obd_connect_flags2str(buf, PAGE_CACHE_SIZE, obd_connect_flags2str(buf, PAGE_CACHE_SIZE,
valid ^ CLIENT_CONNECT_MDT_REQD, ","); valid ^ CLIENT_CONNECT_MDT_REQD, ",");
LCONSOLE_ERROR_MSG(0x170, "Server %s does not support " LCONSOLE_ERROR_MSG(0x170, "Server %s does not support "
...@@ -496,8 +496,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, ...@@ -496,8 +496,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
else if (sbi->ll_flags & LL_SBI_ACL) else if (sbi->ll_flags & LL_SBI_ACL)
valid |= OBD_MD_FLACL; valid |= OBD_MD_FLACL;
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) { if (!op_data) {
err = -ENOMEM; err = -ENOMEM;
goto out_lock_cn_cb; goto out_lock_cn_cb;
} }
...@@ -993,8 +993,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -993,8 +993,8 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
OBD_ALLOC_PTR(cfg); cfg = kzalloc(sizeof(*cfg), GFP_NOFS);
if (cfg == NULL) if (!cfg)
return -ENOMEM; return -ENOMEM;
try_module_get(THIS_MODULE); try_module_get(THIS_MODULE);
...@@ -1049,14 +1049,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) ...@@ -1049,14 +1049,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm, CDEBUG(D_CONFIG, "Found profile %s: mdc=%s osc=%s\n", profilenm,
lprof->lp_md, lprof->lp_dt); lprof->lp_md, lprof->lp_dt);
OBD_ALLOC(dt, strlen(lprof->lp_dt) + instlen + 2); dt = kzalloc(strlen(lprof->lp_dt) + instlen + 2, GFP_NOFS);
if (!dt) { if (!dt) {
err = -ENOMEM; err = -ENOMEM;
goto out_free; goto out_free;
} }
sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance); sprintf(dt, "%s-%p", lprof->lp_dt, cfg->cfg_instance);
OBD_ALLOC(md, strlen(lprof->lp_md) + instlen + 2); md = kzalloc(strlen(lprof->lp_md) + instlen + 2, GFP_NOFS);
if (!md) { if (!md) {
err = -ENOMEM; err = -ENOMEM;
goto out_free; goto out_free;
...@@ -1437,8 +1437,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) ...@@ -1437,8 +1437,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import)
/* We always do an MDS RPC, even if we're only changing the size; /* We always do an MDS RPC, even if we're only changing the size;
* only the MDS knows whether truncate() should fail with -ETXTBUSY */ * only the MDS knows whether truncate() should fail with -ETXTBUSY */
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) if (!op_data)
return -ENOMEM; return -ENOMEM;
if (!S_ISDIR(inode->i_mode)) { if (!S_ISDIR(inode->i_mode)) {
...@@ -2029,7 +2029,7 @@ void ll_umount_begin(struct super_block *sb) ...@@ -2029,7 +2029,7 @@ void ll_umount_begin(struct super_block *sb)
} }
obd->obd_force = 1; obd->obd_force = 1;
OBD_ALLOC_PTR(ioc_data); ioc_data = kzalloc(sizeof(*ioc_data), GFP_NOFS);
if (ioc_data) { if (ioc_data) {
obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp, obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
sizeof(*ioc_data), ioc_data, NULL); sizeof(*ioc_data), ioc_data, NULL);
...@@ -2251,7 +2251,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, ...@@ -2251,7 +2251,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
if (op_data == NULL) if (op_data == NULL)
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) if (op_data == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -106,8 +106,8 @@ struct inode *search_inode_for_lustre(struct super_block *sb, ...@@ -106,8 +106,8 @@ struct inode *search_inode_for_lustre(struct super_block *sb,
/* Because inode is NULL, ll_prep_md_op_data can not /* Because inode is NULL, ll_prep_md_op_data can not
* be used here. So we allocate op_data ourselves */ * be used here. So we allocate op_data ourselves */
OBD_ALLOC_PTR(op_data); op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) if (!op_data)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
op_data->op_fid1 = *fid; op_data->op_fid1 = *fid;
......
...@@ -78,7 +78,7 @@ static struct rmtacl_ctl_entry *rce_alloc(pid_t key, int ops) ...@@ -78,7 +78,7 @@ static struct rmtacl_ctl_entry *rce_alloc(pid_t key, int ops)
{ {
struct rmtacl_ctl_entry *rce; struct rmtacl_ctl_entry *rce;
OBD_ALLOC_PTR(rce); rce = kzalloc(sizeof(*rce), GFP_NOFS);
if (!rce) if (!rce)
return NULL; return NULL;
...@@ -184,7 +184,7 @@ static struct eacl_entry *ee_alloc(pid_t key, struct lu_fid *fid, int type, ...@@ -184,7 +184,7 @@ static struct eacl_entry *ee_alloc(pid_t key, struct lu_fid *fid, int type,
{ {
struct eacl_entry *ee; struct eacl_entry *ee;
OBD_ALLOC_PTR(ee); ee = kzalloc(sizeof(*ee), GFP_NOFS);
if (!ee) if (!ee)
return NULL; return NULL;
......
...@@ -793,11 +793,11 @@ static int __init lloop_init(void) ...@@ -793,11 +793,11 @@ static int __init lloop_init(void)
if (ll_iocontrol_magic == NULL) if (ll_iocontrol_magic == NULL)
goto out_mem1; goto out_mem1;
OBD_ALLOC_WAIT(loop_dev, max_loop * sizeof(*loop_dev)); loop_dev = kzalloc(max_loop * sizeof(*loop_dev), GFP_KERNEL);
if (!loop_dev) if (!loop_dev)
goto out_mem1; goto out_mem1;
OBD_ALLOC_WAIT(disks, max_loop * sizeof(*disks)); disks = kzalloc(max_loop * sizeof(*disks), GFP_KERNEL);
if (!disks) if (!disks)
goto out_mem2; goto out_mem2;
......
...@@ -624,7 +624,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, ...@@ -624,7 +624,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
dentry->d_name.len, dentry->d_name.name, dir->i_ino, dentry->d_name.len, dentry->d_name.name, dir->i_ino,
dir->i_generation, dir, file, open_flags, mode, *opened); dir->i_generation, dir, file, open_flags, mode, *opened);
OBD_ALLOC(it, sizeof(*it)); it = kzalloc(sizeof(*it), GFP_NOFS);
if (!it) if (!it)
return -ENOMEM; return -ENOMEM;
......
...@@ -202,8 +202,8 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, ...@@ -202,8 +202,8 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index,
char *dname; char *dname;
entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4; entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4;
OBD_ALLOC(entry, entry_size); entry = kzalloc(entry_size, GFP_NOFS);
if (unlikely(entry == NULL)) if (unlikely(!entry))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
CDEBUG(D_READA, "alloc sa entry %.*s(%p) index %llu\n", CDEBUG(D_READA, "alloc sa entry %.*s(%p) index %llu\n",
...@@ -465,7 +465,7 @@ static struct ll_statahead_info *ll_sai_alloc(void) ...@@ -465,7 +465,7 @@ static struct ll_statahead_info *ll_sai_alloc(void)
struct ll_statahead_info *sai; struct ll_statahead_info *sai;
int i; int i;
OBD_ALLOC_PTR(sai); sai = kzalloc(sizeof(*sai), GFP_NOFS);
if (!sai) if (!sai)
return NULL; return NULL;
...@@ -802,12 +802,12 @@ static int sa_args_init(struct inode *dir, struct inode *child, ...@@ -802,12 +802,12 @@ static int sa_args_init(struct inode *dir, struct inode *child,
struct ldlm_enqueue_info *einfo; struct ldlm_enqueue_info *einfo;
struct md_op_data *op_data; struct md_op_data *op_data;
OBD_ALLOC_PTR(einfo); einfo = kzalloc(sizeof(*einfo), GFP_NOFS);
if (einfo == NULL) if (!einfo)
return -ENOMEM; return -ENOMEM;
OBD_ALLOC_PTR(minfo); minfo = kzalloc(sizeof(*minfo), GFP_NOFS);
if (minfo == NULL) { if (!minfo) {
OBD_FREE_PTR(einfo); OBD_FREE_PTR(einfo);
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -106,7 +106,7 @@ static int ll_readlink_internal(struct inode *inode, ...@@ -106,7 +106,7 @@ static int ll_readlink_internal(struct inode *inode,
goto failed; goto failed;
} }
OBD_ALLOC(lli->lli_symlink_name, symlen); lli->lli_symlink_name = kzalloc(symlen, GFP_NOFS);
/* do not return an error if we cannot cache the symlink locally */ /* do not return an error if we cannot cache the symlink locally */
if (lli->lli_symlink_name) { if (lli->lli_symlink_name) {
memcpy(lli->lli_symlink_name, *symname, symlen); memcpy(lli->lli_symlink_name, *symname, symlen);
......
...@@ -128,13 +128,13 @@ static int ll_xattr_cache_add(struct list_head *cache, ...@@ -128,13 +128,13 @@ static int ll_xattr_cache_add(struct list_head *cache,
xattr->xe_namelen = strlen(xattr_name) + 1; xattr->xe_namelen = strlen(xattr_name) + 1;
OBD_ALLOC(xattr->xe_name, xattr->xe_namelen); xattr->xe_name = kzalloc(xattr->xe_namelen, GFP_NOFS);
if (!xattr->xe_name) { if (!xattr->xe_name) {
CDEBUG(D_CACHE, "failed to alloc xattr name %u\n", CDEBUG(D_CACHE, "failed to alloc xattr name %u\n",
xattr->xe_namelen); xattr->xe_namelen);
goto err_name; goto err_name;
} }
OBD_ALLOC(xattr->xe_value, xattr_val_len); xattr->xe_value = kzalloc(xattr_val_len, GFP_NOFS);
if (!xattr->xe_value) { if (!xattr->xe_value) {
CDEBUG(D_CACHE, "failed to alloc xattr value %d\n", CDEBUG(D_CACHE, "failed to alloc xattr value %d\n",
xattr_val_len); xattr_val_len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment