From: pschwan Date: Sat, 23 Feb 2002 19:06:25 +0000 (+0000) Subject: - Converted lots of debugging printks to CDEBUGs X-Git-Tag: 0.4.2~605 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=748650f164a499d4e4e06a1271aee8b4c4323518;p=fs%2Flustre-release.git - Converted lots of debugging printks to CDEBUGs - Removed duplicated debug macros and defines; they live in portals now - All of OBD's debug information now lives in the Portals debug buffer. Use 'ptlctl get_debug' to view the buffer. The buffer's size is currently hardcoded at 1 megabyte in module.c, but that's easy enough to change to a module argument. --- diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 9a9e928..c92e40f 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -22,8 +22,8 @@ * */ -#ifndef _CFS_LIB_H -#define _CFS_LIB_H +#ifndef _LUSTRE_LIB_H +#define _LUSTRE_LIB_H #include @@ -39,147 +39,6 @@ void lustre_prepare_page(unsigned from, unsigned to, struct page *page); int lustre_commit_page(struct page *page, unsigned from, unsigned to); #endif - -/* macros */ -#undef MIN -#define MIN(a,b) (((a)<(b)) ? (a): (b)) -#undef MAX -#define MAX(a,b) (((a)>(b)) ? (a): (b)) -#define MKSTR(ptr) ((ptr))? (ptr) : "" - -static inline int size_round (int val) -{ - return (val + 3) & (~0x3); -} - -static inline int size_round0(int val) -{ - if (!val) - return 0; - return (val + 1 + 3) & (~0x3); -} - -static inline size_t round_strlen(char *fset) -{ - return size_round(strlen(fset) + 1); -} - -#ifdef __KERNEL__ -static inline char *strdup(char *str) -{ - char *tmp = kmalloc(strlen(str) + 1, GFP_KERNEL); - if (tmp) - memcpy(tmp, str, strlen(str) + 1); - - return NULL; -} -#endif - -#ifdef __KERNEL__ -# define NTOH__u32(var) le32_to_cpu(var) -# define NTOH__u64(var) le64_to_cpu(var) -# define HTON__u32(var) cpu_to_le32(var) -# define HTON__u64(var) cpu_to_le64(var) -#else -# include -# define NTOH__u32(var) GUINT32_FROM_LE(var) -# define NTOH__u64(var) GUINT64_FROM_LE(var) -# define HTON__u32(var) GUINT32_TO_LE(var) -# define HTON__u64(var) GUINT64_TO_LE(var) -#endif - -/* - * copy sizeof(type) bytes from pointer to var and move ptr forward. - * return EFAULT if pointer goes beyond end - */ -#define UNLOGV(var,type,ptr,end) \ -do { \ - var = *(type *)ptr; \ - ptr += sizeof(type); \ - if (ptr > end ) \ - return -EFAULT; \ -} while (0) - -/* the following two macros convert to little endian */ -/* type MUST be __u32 or __u64 */ -#define LUNLOGV(var,type,ptr,end) \ -do { \ - var = NTOH##type(*(type *)ptr); \ - ptr += sizeof(type); \ - if (ptr > end ) \ - return -EFAULT; \ -} while (0) - -/* now log values */ -#define LOGV(var,type,ptr) \ -do { \ - *((type *)ptr) = var; \ - ptr += sizeof(type); \ -} while (0) - -/* and in network order */ -#define LLOGV(var,type,ptr) \ -do { \ - *((type *)ptr) = HTON##type(var); \ - ptr += sizeof(type); \ -} while (0) - - -/* - * set var to point at (type *)ptr, move ptr forward with sizeof(type) - * return from function with EFAULT if ptr goes beyond end - */ -#define UNLOGP(var,type,ptr,end) \ -do { \ - var = (type *)ptr; \ - ptr += sizeof(type); \ - if (ptr > end ) \ - return -EFAULT; \ -} while (0) - -#define LOGP(var,type,ptr) \ -do { \ - memcpy(ptr, var, sizeof(type)); \ - ptr += sizeof(type); \ -} while (0) - -/* - * set var to point at (char *)ptr, move ptr forward by size_round(len); - * return from function with EFAULT if ptr goes beyond end - */ -#define UNLOGL(var,type,len,ptr,end) \ -do { \ - if (!len) { \ - var = NULL; \ - break; \ - } \ - var = (type *)ptr; \ - ptr += size_round(len * sizeof(type)); \ - if (ptr > end ) \ - return -EFAULT; \ -} while (0) - -#define UNLOGL0(var,type,len,ptr,end) \ -do { \ - UNLOGL(var,type,len,ptr,end); \ - if ( *((char *)ptr - size_round(len) + len - 1) != '\0')\ - return -EFAULT; \ -} while (0) - - -#define LOGL(var,len,ptr) \ -do { \ - if (!len) break; \ - memcpy((char *)ptr, (const char *)var, len); \ - ptr += size_round(len); \ -} while (0) - -#define LOGL0(var,len,ptr) \ -do { \ - if (!len) break; \ - memcpy((char *)ptr, (const char *)var, len); \ - *((char *)(ptr) + len) = 0; \ - ptr += size_round(len + 1); \ -} while (0) +#include #endif /* _LUSTRE_LIB_H */ diff --git a/lustre/include/linux/obd_support.h b/lustre/include/linux/obd_support.h index 7d76129..8ffedcf 100644 --- a/lustre/include/linux/obd_support.h +++ b/lustre/include/linux/obd_support.h @@ -9,6 +9,7 @@ #include #include +#include #define obd_unlock_page(page) \ do { \ @@ -35,46 +36,15 @@ extern long obd_memory; #ifdef EXT2_OBD_DEBUG #define CMD(cmd) (( cmd == READ ) ? "read" : "write") -/* debugging masks */ -#define D_PSDEV 0x001 /* debug information from psdev.c */ -#define D_INODE 0x002 -#define D_SUPER 0x004 -#define D_SNAP 0x008 -#define D_UNUSED4 0x010 -#define D_WARNING 0x020 /* misc warnings */ -#define D_EXT2 0x040 /* anything from ext2_debug */ -#define D_MALLOC 0x080 /* print malloc, free information */ -#define D_CACHE 0x100 /* cache-related items */ -#define D_INFO 0x200 /* general information, especially from interface.c */ -#define D_IOCTL 0x400 /* ioctl related information */ -#define D_BLOCKS 0x800 /* ext2 block allocation */ -#define D_NET 0x1000 /* network communications */ -#define D_PUNCH 0x2000 -#define D_BUFFS 0x4000 /* print network buffers */ - -#define CDEBUG(mask, format, a...) \ - do { \ - if (obd_debug_level & mask) { \ - printk("(%s:%d):", __FUNCTION__, __LINE__); \ - printk(format, ## a); } \ - } while (0) - -#define ENTRY if (obd_print_entry) \ - printk(KERN_INFO "Process %d entered %s\n", current->pid, __FUNCTION__) - -#define EXIT if (obd_print_entry) \ - printk(KERN_INFO "Process %d leaving %s [%d]\n", current->pid, \ - __FUNCTION__, __LINE__) - /* Inode common information printed out (used by obdfs and ext2obd inodes) */ #define ICDEBUG(inode) { \ - CDEBUG(D_INFO, \ - "ino %ld, atm %ld, mtm %ld, ctm %ld, size %Ld, blocks %ld\n",\ - inode->i_ino, inode->i_atime, inode->i_mtime, inode->i_ctime,\ - inode->i_size, inode->i_blocks); \ + CDEBUG(D_INFO, "ino %ld, atm %ld, mtm %ld, ctm %ld, size %Ld, " \ + "blocks %ld\n", inode->i_ino, inode->i_atime, \ + inode->i_mtime, inode->i_ctime, inode->i_size, \ + inode->i_blocks); \ CDEBUG(D_INFO, "mode %o, uid %d, gid %d, nlnk %d, count %d\n", \ - inode->i_mode, inode->i_uid, inode->i_gid, inode->i_nlink,\ - atomic_read(&inode->i_count)); \ + inode->i_mode, inode->i_uid, inode->i_gid, \ + inode->i_nlink, atomic_read(&inode->i_count)); \ } /* Ext2 inode information */ @@ -106,7 +76,6 @@ extern long obd_memory; (obdo)->o_obdflags, (obdo)->o_nlink, (obdo)->o_valid); \ } - #define PDEBUG(page,msg) { \ if (page){ \ char *uptodate = (Page_Uptodate(page)) ? "upto" : "outof";\ diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index b746770..9577ce1 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -163,7 +163,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, rep->nlink = 1; rep->atime = rep->ctime = rep->mtime = time; rep->mode = mode; - printk("-- new_inode: objid %lld, ino %d, mode %o\n", + CDEBUG(D_LLIGHT, "-- new_inode: objid %lld, ino %d, mode %o\n", rep->objid, rep->ino, rep->mode); inode = iget4(dir->i_sb, rep->ino, NULL, rep); @@ -285,7 +285,7 @@ static int ll_create (struct inode * dir, struct dentry * dentry, int mode) } mode = mode | S_IFREG; - printk("ll_create: name %s mode %o\n", dentry->d_name.name, mode); + CDEBUG(D_LLIGHT, "name %s mode %o\n", dentry->d_name.name, mode); inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, oa.o_id); diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 0f647e0..b3d6e61 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -63,7 +63,7 @@ static char *ll_read_opt(const char *opt, char *data) } memcpy(retval, value, strlen(value)+1); - CDEBUG(D_PSDEV, "Assigned option: %s, value %s\n", opt, retval); + CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); EXIT; return retval; } @@ -211,8 +211,8 @@ static void ll_delete_inode(struct inode *inode) } err = obd_destroy(IID(inode), oa); - printk(__FUNCTION__ ": obd destroy of %Ld error %d\n", - oa->o_id, err); + CDEBUG(D_LLIGHT, "obd destroy of %Ld error %d\n", + oa->o_id, err); obdo_free(oa); } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index a22582e..3235088 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -77,7 +77,7 @@ struct ptlrpc_request *mds_prep_req(int opcode, int namelen, char *name, printk("llight request: cannot pack request %d\n", rc); return NULL; } - printk("--> mds_prep_req: len %d, req %p, tgtlen %d\n", + CDEBUG(D_MDC, "--> mds_prep_req: len %d, req %p, tgtlen %d\n", request->rq_reqlen, request->rq_req.mds, request->rq_req.mds->tgtlen); request->rq_reqhdr->opc = opcode; @@ -93,7 +93,7 @@ static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer) /* XXX fix the race here (wait_for_event?)*/ if (peer == NULL) { /* Local delivery */ - printk("--->> %s %d\n", __FUNCTION__, __LINE__); + ENTRY; rc = mds_queue_req(req); } else { /* Remote delivery via portals. */ @@ -108,9 +108,9 @@ static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer) } init_waitqueue_head(&req->rq_wait_for_rep); - printk("-- sleeping\n"); + CDEBUG(D_MDC, "-- sleeping\n"); interruptible_sleep_on(&req->rq_wait_for_rep); - printk("-- done\n"); + CDEBUG(D_MDC, "-- done\n"); rc = mds_unpack_rep(req->rq_repbuf, req->rq_replen, &req->rq_rephdr, &req->rq_rep.mds); @@ -120,7 +120,7 @@ static int mds_queue_wait(struct ptlrpc_request *req, struct lustre_peer *peer) } if ( req->rq_rephdr->status == 0 ) - printk("-->mdc_queue_wait: buf %p len %d status %d\n", + CDEBUG(D_MDC, "--> buf %p len %d status %d\n", req->rq_repbuf, req->rq_replen, req->rq_rephdr->status); @@ -157,7 +157,7 @@ int mdc_getattr(struct lustre_peer *peer, ino_t ino, int type, int valid, goto out; } - printk("mds_getattr: mode: %o\n", request->rq_rep.mds->mode); + CDEBUG(D_MDC, "mode: %o\n", request->rq_rep.mds->mode); if (rep) { *rep = request->rq_rep.mds; @@ -180,7 +180,7 @@ int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, niobuf.addr = (__u64) (long) addr; - printk("mdc_readpage: inode: %ld\n", ino); + CDEBUG(D_MDC, "inode: %ld\n", ino); request = mds_prep_req(MDS_READPAGE, 0, NULL, sizeof(struct niobuf), (char *)&niobuf); @@ -204,7 +204,7 @@ int mdc_readpage(struct lustre_peer *peer, ino_t ino, int type, __u64 offset, goto out; } - printk("mdc_readpage: mode: %o\n", request->rq_rep.mds->mode); + CDEBUG(D_MDC, "mode: %o\n", request->rq_rep.mds->mode); if (rep) { *rep = request->rq_rep.mds; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index c9cb6c6..33d12db 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -53,7 +53,7 @@ static int mds_queue_req(struct ptlrpc_request *req) return -ENOMEM; } - printk("---> MDS at %d %p, incoming req %p, srv_req %p\n", + CDEBUG(D_MDS, "---> MDS at %d %p, incoming req %p, srv_req %p\n", __LINE__, MDS, req, srv_req); memset(srv_req, 0, sizeof(*req)); @@ -190,7 +190,7 @@ struct dentry *mds_fid2dentry(struct mds_obd *mds, struct ll_fid *fid, if (inode == NULL) return ERR_PTR(-ENOMEM); - printk("--> mds_fid2dentry: sb %p\n", inode->i_sb); + CDEBUG(D_MDS, "--> mds_fid2dentry: sb %p\n", inode->i_sb); if (is_bad_inode(inode) || (generation && inode->i_generation != generation) @@ -311,7 +311,7 @@ int mds_readpage(struct ptlrpc_request *req) return 0; } - printk("mds_readpage: ino %ld\n", de->d_inode->i_ino); + CDEBUG(D_MDS, "ino %ld\n", de->d_inode->i_ino); file = dentry_open(de, mnt, O_RDONLY | O_LARGEFILE); /* note: in case of an error, dentry_open puts dentry */ diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index bb94080..fc9beaa 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -43,7 +43,7 @@ static int mds_reint_setattr(struct mds_update_record *rec, struct ptlrpc_reques return 0; } - printk("mds_setattr: ino %ld\n", de->d_inode->i_ino); + CDEBUG(D_MDS, "ino %ld\n", de->d_inode->i_ino); /* a _really_ horrible hack to avoid removing the data stored in the block pointers; this data is the object id @@ -99,7 +99,7 @@ static int mds_reint_create(struct mds_update_record *rec, EXIT; return 0; } - printk("mds_reint_create: ino %ld\n", de->d_inode->i_ino); + CDEBUG(D_MDS, "ino %ld\n", de->d_inode->i_ino); dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1); rc = PTR_ERR(dchild); @@ -180,7 +180,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, EXIT; return 0; } - printk("mds_reint_create: ino %ld\n", de->d_inode->i_ino); + CDEBUG(D_MDS, "ino %ld\n", de->d_inode->i_ino); dchild = lookup_one_len(rec->ur_name, de, rec->ur_namelen - 1); rc = PTR_ERR(dchild); diff --git a/lustre/obdfs/super.c b/lustre/obdfs/super.c index 7a9481aa..9804e61 100644 --- a/lustre/obdfs/super.c +++ b/lustre/obdfs/super.c @@ -63,7 +63,7 @@ static char *obdfs_read_opt(const char *opt, char *data) } memcpy(retval, value, strlen(value)+1); - CDEBUG(D_PSDEV, "Assigned option: %s, value %s\n", opt, retval); + CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); return retval; } diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 060c5c3..6ddc563 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -55,7 +55,7 @@ static int ost_queue_req(struct obd_device *obddev, struct ptlrpc_request *req) return -ENOMEM; } - printk("---> OST at %d %p, incoming req %p, srv_req %p\n", + CDEBUG(D_OST, "---> OST at %d %p, incoming req %p, srv_req %p\n", __LINE__, ost, req, srv_req); memset(srv_req, 0, sizeof(*req)); @@ -160,7 +160,6 @@ static int ost_getattr(struct ost_obd *ost, struct ptlrpc_request *req) int rc; ENTRY; - printk("ost getattr entered\n"); conn.oc_id = req->rq_req.ost->connid; conn.oc_dev = ost->ost_tgt; @@ -253,7 +252,7 @@ static int ost_connect(struct ost_obd *ost, struct ptlrpc_request *req) req->rq_rep.ost->result =ost->ost_tgt->obd_type->typ_ops->o_connect(&conn); - printk("ost_connect: rep buffer %p, id %d\n", req->rq_repbuf, + CDEBUG(D_OST, "ost_connect: rep buffer %p, id %d\n", req->rq_repbuf, conn.oc_id); req->rq_rep.ost->connid = conn.oc_id; EXIT; @@ -398,7 +397,7 @@ int ost_handle(struct obd_device *obddev, struct ptlrpc_request *req) struct ptlreq_hdr *hdr; ENTRY; - printk("ost_handle: req at %p\n", req); + CDEBUG(D_OST, "req at %p\n", req); hdr = (struct ptlreq_hdr *)req->rq_reqbuf; if (NTOH__u32(hdr->type) != OST_TYPE_REQ) { diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index b61b8ce..372c3c5 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -476,4 +476,3 @@ MODULE_LICENSE("GPL"); module_init(ptlrpc_init); module_exit(ptlrpc_exit); - diff --git a/lustre/utils/Makefile.am b/lustre/utils/Makefile.am index c41edd8..d632f12 100644 --- a/lustre/utils/Makefile.am +++ b/lustre/utils/Makefile.am @@ -3,7 +3,7 @@ DEFS:= bin_SCRIPTS = obdcontrol EXTRA_DIST = $(bin_SCRIPTS) -CFLAGS:=-g -I. -I/usr/include/glib-1.2 -I/usr/lib/glib/include -I../include -Wall +CFLAGS:=-g -I. -I/usr/include/glib-1.2 -I$(PORTALS)/include -I/usr/lib/glib/include -I../include -Wall KFLAGS:= CPPFLAGS := LDADD := -lreadline -ltermcap # -lefence