2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-20 16:46:23 +08:00

[GFS2] Audit printk and kmalloc

All printk calls now have KERN_ set where required and a couple of
kmalloc(), memset(.., 0, ...) calls changed to kzalloc().

This is in response to comments from:
Pekka Enberg <penberg@cs.helsinki.fi> and
Eric Sesterhenn <snakebyte@gmx.de>

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
Steven Whitehouse 2006-02-27 10:57:14 -05:00
parent 2fcb4a1278
commit d92a8d4808
10 changed files with 64 additions and 66 deletions

View File

@ -2315,17 +2315,17 @@ static int dump_holder(char *str, struct gfs2_holder *gh)
unsigned int x; unsigned int x;
int error = -ENOBUFS; int error = -ENOBUFS;
printk(" %s\n", str); printk(KERN_INFO " %s\n", str);
printk(" owner = %ld\n", printk(KERN_INFO " owner = %ld\n",
(gh->gh_owner) ? (long)gh->gh_owner->pid : -1); (gh->gh_owner) ? (long)gh->gh_owner->pid : -1);
printk(" gh_state = %u\n", gh->gh_state); printk(KERN_INFO " gh_state = %u\n", gh->gh_state);
printk(" gh_flags ="); printk(KERN_INFO " gh_flags =");
for (x = 0; x < 32; x++) for (x = 0; x < 32; x++)
if (gh->gh_flags & (1 << x)) if (gh->gh_flags & (1 << x))
printk(" %u", x); printk(" %u", x);
printk(" \n"); printk(" \n");
printk(" error = %d\n", gh->gh_error); printk(KERN_INFO " error = %d\n", gh->gh_error);
printk(" gh_iflags ="); printk(KERN_INFO " gh_iflags =");
for (x = 0; x < 32; x++) for (x = 0; x < 32; x++)
if (test_bit(x, &gh->gh_iflags)) if (test_bit(x, &gh->gh_iflags))
printk(" %u", x); printk(" %u", x);
@ -2348,17 +2348,17 @@ static int dump_inode(struct gfs2_inode *ip)
unsigned int x; unsigned int x;
int error = -ENOBUFS; int error = -ENOBUFS;
printk(" Inode:\n"); printk(KERN_INFO " Inode:\n");
printk(" num = %llu %llu\n", printk(KERN_INFO " num = %llu %llu\n",
ip->i_num.no_formal_ino, ip->i_num.no_addr); ip->i_num.no_formal_ino, ip->i_num.no_addr);
printk(" type = %u\n", IF2DT(ip->i_di.di_mode)); printk(KERN_INFO " type = %u\n", IF2DT(ip->i_di.di_mode));
printk(" i_count = %d\n", atomic_read(&ip->i_count)); printk(KERN_INFO " i_count = %d\n", atomic_read(&ip->i_count));
printk(" i_flags ="); printk(KERN_INFO " i_flags =");
for (x = 0; x < 32; x++) for (x = 0; x < 32; x++)
if (test_bit(x, &ip->i_flags)) if (test_bit(x, &ip->i_flags))
printk(" %u", x); printk(" %u", x);
printk(" \n"); printk(" \n");
printk(" vnode = %s\n", (ip->i_vnode) ? "yes" : "no"); printk(KERN_INFO " vnode = %s\n", (ip->i_vnode) ? "yes" : "no");
error = 0; error = 0;
@ -2381,30 +2381,30 @@ static int dump_glock(struct gfs2_glock *gl)
spin_lock(&gl->gl_spin); spin_lock(&gl->gl_spin);
printk("Glock (%u, %llu)\n", printk(KERN_INFO "Glock (%u, %llu)\n",
gl->gl_name.ln_type, gl->gl_name.ln_type,
gl->gl_name.ln_number); gl->gl_name.ln_number);
printk(" gl_flags ="); printk(KERN_INFO " gl_flags =");
for (x = 0; x < 32; x++) for (x = 0; x < 32; x++)
if (test_bit(x, &gl->gl_flags)) if (test_bit(x, &gl->gl_flags))
printk(" %u", x); printk(" %u", x);
printk(" \n"); printk(" \n");
printk(" gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount)); printk(KERN_INFO " gl_ref = %d\n", atomic_read(&gl->gl_ref.refcount));
printk(" gl_state = %u\n", gl->gl_state); printk(KERN_INFO " gl_state = %u\n", gl->gl_state);
printk(" req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no"); printk(KERN_INFO " req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no");
printk(" req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no"); printk(KERN_INFO " req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no");
printk(" lvb_count = %d\n", atomic_read(&gl->gl_lvb_count)); printk(KERN_INFO " lvb_count = %d\n", atomic_read(&gl->gl_lvb_count));
printk(" object = %s\n", (gl->gl_object) ? "yes" : "no"); printk(KERN_INFO " object = %s\n", (gl->gl_object) ? "yes" : "no");
printk(" le = %s\n", printk(KERN_INFO " le = %s\n",
(list_empty(&gl->gl_le.le_list)) ? "no" : "yes"); (list_empty(&gl->gl_le.le_list)) ? "no" : "yes");
printk(" reclaim = %s\n", printk(KERN_INFO " reclaim = %s\n",
(list_empty(&gl->gl_reclaim)) ? "no" : "yes"); (list_empty(&gl->gl_reclaim)) ? "no" : "yes");
if (gl->gl_aspace) if (gl->gl_aspace)
printk(" aspace = %lu\n", printk(KERN_INFO " aspace = %lu\n",
gl->gl_aspace->i_mapping->nrpages); gl->gl_aspace->i_mapping->nrpages);
else else
printk(" aspace = no\n"); printk(KERN_INFO " aspace = no\n");
printk(" ail = %d\n", atomic_read(&gl->gl_ail_count)); printk(KERN_INFO " ail = %d\n", atomic_read(&gl->gl_ail_count));
if (gl->gl_req_gh) { if (gl->gl_req_gh) {
error = dump_holder("Request", gl->gl_req_gh); error = dump_holder("Request", gl->gl_req_gh);
if (error) if (error)
@ -2438,7 +2438,7 @@ static int dump_glock(struct gfs2_glock *gl)
goto out; goto out;
} else { } else {
error = -ENOBUFS; error = -ENOBUFS;
printk(" Inode: busy\n"); printk(KERN_INFO " Inode: busy\n");
} }
} }

View File

@ -46,18 +46,17 @@ int gfs_register_lockproto(struct lm_lockops *proto)
list_for_each_entry(lw, &lmh_list, lw_list) { list_for_each_entry(lw, &lmh_list, lw_list) {
if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) { if (!strcmp(lw->lw_ops->lm_proto_name, proto->lm_proto_name)) {
up(&lmh_lock); up(&lmh_lock);
printk("GFS2: protocol %s already exists\n", printk(KERN_INFO "GFS2: protocol %s already exists\n",
proto->lm_proto_name); proto->lm_proto_name);
return -EEXIST; return -EEXIST;
} }
} }
lw = kmalloc(sizeof(struct lmh_wrapper), GFP_KERNEL); lw = kzalloc(sizeof(struct lmh_wrapper), GFP_KERNEL);
if (!lw) { if (!lw) {
up(&lmh_lock); up(&lmh_lock);
return -ENOMEM; return -ENOMEM;
} }
memset(lw, 0, sizeof(struct lmh_wrapper));
lw->lw_ops = proto; lw->lw_ops = proto;
list_add(&lw->lw_list, &lmh_list); list_add(&lw->lw_list, &lmh_list);
@ -90,7 +89,7 @@ void gfs_unregister_lockproto(struct lm_lockops *proto)
up(&lmh_lock); up(&lmh_lock);
printk("GFS2: can't unregister lock protocol %s\n", printk(KERN_WARNING "GFS2: can't unregister lock protocol %s\n",
proto->lm_proto_name); proto->lm_proto_name);
} }
@ -136,7 +135,7 @@ int gfs2_mount_lockproto(char *proto_name, char *table_name, char *host_data,
request_module(proto_name); request_module(proto_name);
goto retry; goto retry;
} }
printk("GFS2: can't find protocol %s\n", proto_name); printk(KERN_INFO "GFS2: can't find protocol %s\n", proto_name);
error = -ENOENT; error = -ENOENT;
goto out; goto out;
} }

View File

@ -34,7 +34,7 @@ static inline void gdlm_bast(void *astarg, int mode)
struct gdlm_ls *ls = lp->ls; struct gdlm_ls *ls = lp->ls;
if (!mode) { if (!mode) {
printk("lock_dlm: bast mode zero %x,%llx\n", printk(KERN_INFO "lock_dlm: bast mode zero %x,%llx\n",
lp->lockname.ln_type, lp->lockname.ln_number); lp->lockname.ln_type, lp->lockname.ln_number);
return; return;
} }
@ -408,7 +408,7 @@ static int hold_null_lock(struct gdlm_lock *lp)
int error; int error;
if (lp->hold_null) { if (lp->hold_null) {
printk("lock_dlm: lvb already held\n"); printk(KERN_INFO "lock_dlm: lvb already held\n");
return 0; return 0;
} }
@ -429,7 +429,8 @@ static int hold_null_lock(struct gdlm_lock *lp)
wait_for_completion(&lpn->ast_wait); wait_for_completion(&lpn->ast_wait);
error = lp->lksb.sb_status; error = lp->lksb.sb_status;
if (error) { if (error) {
printk("lock_dlm: hold_null_lock dlm error %d\n", error); printk(KERN_INFO "lock_dlm: hold_null_lock dlm error %d\n",
error);
gdlm_delete_lp(lpn); gdlm_delete_lp(lpn);
lpn = NULL; lpn = NULL;
} }

View File

@ -22,7 +22,7 @@ int __init init_lock_dlm(void)
error = gfs_register_lockproto(&gdlm_ops); error = gfs_register_lockproto(&gdlm_ops);
if (error) { if (error) {
printk("lock_dlm: can't register protocol: %d\n", error); printk(KERN_WARNING "lock_dlm: can't register protocol: %d\n", error);
return error; return error;
} }
@ -42,7 +42,7 @@ int __init init_lock_dlm(void)
gdlm_drop_count = GDLM_DROP_COUNT; gdlm_drop_count = GDLM_DROP_COUNT;
gdlm_drop_period = GDLM_DROP_PERIOD; gdlm_drop_period = GDLM_DROP_PERIOD;
printk("Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__); printk(KERN_INFO "Lock_DLM (built %s %s) installed\n", __DATE__, __TIME__);
return 0; return 0;
} }

View File

@ -83,7 +83,7 @@ int gdlm_plock(lm_lockspace_t *lockspace, struct lm_lockname *name,
spin_lock(&ops_lock); spin_lock(&ops_lock);
if (!list_empty(&op->list)) { if (!list_empty(&op->list)) {
printk("plock op on list\n"); printk(KERN_INFO "plock op on list\n");
list_del(&op->list); list_del(&op->list);
} }
spin_unlock(&ops_lock); spin_unlock(&ops_lock);
@ -127,7 +127,7 @@ int gdlm_punlock(lm_lockspace_t *lockspace, struct lm_lockname *name,
spin_lock(&ops_lock); spin_lock(&ops_lock);
if (!list_empty(&op->list)) { if (!list_empty(&op->list)) {
printk("punlock op on list\n"); printk(KERN_INFO "punlock op on list\n");
list_del(&op->list); list_del(&op->list);
} }
spin_unlock(&ops_lock); spin_unlock(&ops_lock);
@ -162,7 +162,7 @@ int gdlm_plock_get(lm_lockspace_t *lockspace, struct lm_lockname *name,
spin_lock(&ops_lock); spin_lock(&ops_lock);
if (!list_empty(&op->list)) { if (!list_empty(&op->list)) {
printk("plock_get op on list\n"); printk(KERN_INFO "plock_get op on list\n");
list_del(&op->list); list_del(&op->list);
} }
spin_unlock(&ops_lock); spin_unlock(&ops_lock);
@ -242,7 +242,7 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
if (found) if (found)
wake_up(&recv_wq); wake_up(&recv_wq);
else else
printk("gdlm dev_write no op %x %llx\n", info.fsid, printk(KERN_INFO "gdlm dev_write no op %x %llx\n", info.fsid,
info.number); info.number);
return count; return count;
} }
@ -285,13 +285,14 @@ int gdlm_plock_init(void)
rv = misc_register(&plock_dev_misc); rv = misc_register(&plock_dev_misc);
if (rv) if (rv)
printk("gdlm_plock_init: misc_register failed %d", rv); printk(KERN_INFO "gdlm_plock_init: misc_register failed %d",
rv);
return rv; return rv;
} }
void gdlm_plock_exit(void) void gdlm_plock_exit(void)
{ {
if (misc_deregister(&plock_dev_misc) < 0) if (misc_deregister(&plock_dev_misc) < 0)
printk("gdlm_plock_exit: misc_deregister failed"); printk(KERN_INFO "gdlm_plock_exit: misc_deregister failed");
} }

View File

@ -44,11 +44,10 @@ static int nolock_mount(char *table_name, char *host_data,
sscanf(c, "%u", &jid); sscanf(c, "%u", &jid);
} }
nl = kmalloc(sizeof(struct nolock_lockspace), GFP_KERNEL); nl = kzalloc(sizeof(struct nolock_lockspace), GFP_KERNEL);
if (!nl) if (!nl)
return -ENOMEM; return -ENOMEM;
memset(nl, 0, sizeof(struct nolock_lockspace));
nl->nl_lvb_size = min_lvb_size; nl->nl_lvb_size = min_lvb_size;
lockstruct->ls_jid = jid; lockstruct->ls_jid = jid;
@ -147,10 +146,8 @@ static int nolock_hold_lvb(lm_lock_t *lock, char **lvbp)
struct nolock_lockspace *nl = (struct nolock_lockspace *)lock; struct nolock_lockspace *nl = (struct nolock_lockspace *)lock;
int error = 0; int error = 0;
*lvbp = kmalloc(nl->nl_lvb_size, GFP_KERNEL); *lvbp = kzalloc(nl->nl_lvb_size, GFP_KERNEL);
if (*lvbp) if (!*lvbp)
memset(*lvbp, 0, nl->nl_lvb_size);
else
error = -ENOMEM; error = -ENOMEM;
return error; return error;
@ -246,11 +243,11 @@ int __init init_nolock(void)
error = gfs_register_lockproto(&nolock_ops); error = gfs_register_lockproto(&nolock_ops);
if (error) { if (error) {
printk("lock_nolock: can't register protocol: %d\n", error); printk(KERN_WARNING "lock_nolock: can't register protocol: %d\n", error);
return error; return error;
} }
printk("Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__); printk(KERN_INFO "Lock_Nolock (built %s %s) installed\n", __DATE__, __TIME__);
return 0; return 0;
} }

View File

@ -17,7 +17,7 @@
#include "gfs2.h" #include "gfs2.h"
#include <linux/gfs2_ondisk.h> #include <linux/gfs2_ondisk.h>
#define pv(struct, member, fmt) printk(" "#member" = "fmt"\n", struct->member); #define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", struct->member);
#define pa(struct, member, count) print_array(#member, struct->member, count); #define pa(struct, member, count) print_array(#member, struct->member, count);
/** /**
@ -32,11 +32,11 @@ static void print_array(char *title, char *buf, int count)
{ {
int x; int x;
printk(" %s =\n", title); printk(KERN_INFO " %s =\n" KERN_INFO, title);
for (x = 0; x < count; x++) { for (x = 0; x < count; x++) {
printk("%.2X ", (unsigned char)buf[x]); printk("%.2X ", (unsigned char)buf[x]);
if (x % 16 == 15) if (x % 16 == 15)
printk("\n"); printk("\n" KERN_INFO);
} }
if (x % 16) if (x % 16)
printk("\n"); printk("\n");
@ -338,7 +338,7 @@ void gfs2_dirent_print(struct gfs2_dirent *de, char *name)
memset(buf, 0, GFS2_FNAMESIZE + 1); memset(buf, 0, GFS2_FNAMESIZE + 1);
memcpy(buf, name, de->de_name_len); memcpy(buf, name, de->de_name_len);
printk(" name = %s\n", buf); printk(KERN_INFO " name = %s\n", buf);
} }
void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf) void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
@ -401,7 +401,7 @@ void gfs2_ea_header_print(struct gfs2_ea_header *ea, char *name)
memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1); memset(buf, 0, GFS2_EA_MAX_NAME_LEN + 1);
memcpy(buf, name, ea->ea_name_len); memcpy(buf, name, ea->ea_name_len);
printk(" name = %s\n", buf); printk(KERN_INFO " name = %s\n", buf);
} }
void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf) void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)

View File

@ -772,13 +772,13 @@ static int fill_super(struct super_block *sb, void *data, int silent)
sdp = init_sbd(sb); sdp = init_sbd(sb);
if (!sdp) { if (!sdp) {
printk("GFS2: can't alloc struct gfs2_sbd\n"); printk(KERN_WARNING "GFS2: can't alloc struct gfs2_sbd\n");
return -ENOMEM; return -ENOMEM;
} }
error = gfs2_mount_args(sdp, (char *)data, 0); error = gfs2_mount_args(sdp, (char *)data, 0);
if (error) { if (error) {
printk("GFS2: can't parse mount arguments\n"); printk(KERN_WARNING "GFS2: can't parse mount arguments\n");
goto fail; goto fail;
} }

View File

@ -12,8 +12,8 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/vmalloc.h>
#include <linux/statfs.h> #include <linux/statfs.h>
#include <linux/vmalloc.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/kthread.h> #include <linux/kthread.h>

View File

@ -94,7 +94,7 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
if (sb->sb_header.mh_magic != GFS2_MAGIC || if (sb->sb_header.mh_magic != GFS2_MAGIC ||
sb->sb_header.mh_type != GFS2_METATYPE_SB) { sb->sb_header.mh_type != GFS2_METATYPE_SB) {
if (!silent) if (!silent)
printk("GFS2: not a GFS2 filesystem\n"); printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n");
return -EINVAL; return -EINVAL;
} }
@ -110,11 +110,11 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
break; break;
if (!gfs2_old_fs_formats[x]) { if (!gfs2_old_fs_formats[x]) {
printk("GFS2: code version (%u, %u) is incompatible " printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible "
"with ondisk format (%u, %u)\n", "with ondisk format (%u, %u)\n",
GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
sb->sb_fs_format, sb->sb_multihost_format); sb->sb_fs_format, sb->sb_multihost_format);
printk("GFS2: I don't know how to upgrade this FS\n"); printk(KERN_WARNING "GFS2: I don't know how to upgrade this FS\n");
return -EINVAL; return -EINVAL;
} }
} }
@ -125,23 +125,23 @@ int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
break; break;
if (!gfs2_old_multihost_formats[x]) { if (!gfs2_old_multihost_formats[x]) {
printk("GFS2: code version (%u, %u) is incompatible " printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible "
"with ondisk format (%u, %u)\n", "with ondisk format (%u, %u)\n",
GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
sb->sb_fs_format, sb->sb_multihost_format); sb->sb_fs_format, sb->sb_multihost_format);
printk("GFS2: I don't know how to upgrade this FS\n"); printk(KERN_WARNING "GFS2: I don't know how to upgrade this FS\n");
return -EINVAL; return -EINVAL;
} }
} }
if (!sdp->sd_args.ar_upgrade) { if (!sdp->sd_args.ar_upgrade) {
printk("GFS2: code version (%u, %u) is incompatible " printk(KERN_WARNING "GFS2: code version (%u, %u) is incompatible "
"with ondisk format (%u, %u)\n", "with ondisk format (%u, %u)\n",
GFS2_FORMAT_FS, GFS2_FORMAT_MULTI, GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
sb->sb_fs_format, sb->sb_multihost_format); sb->sb_fs_format, sb->sb_multihost_format);
printk("GFS2: Use the \"upgrade\" mount option to upgrade " printk(KERN_INFO "GFS2: Use the \"upgrade\" mount option to upgrade "
"the FS\n"); "the FS\n");
printk("GFS2: See the manual for more details\n"); printk(KERN_INFO "GFS2: See the manual for more details\n");
return -EINVAL; return -EINVAL;
} }