Re: [PATCH 2/2] Use the cut_here() function in AFS, CacheFiles, FS-Cache and RxRPC

From: David Howells
Date: Thu Aug 20 2009 - 12:06:49 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> instead. And yes, in the long run, I really think we should just extend
> the current BUG() reporting to have that kind of semantics, but I think
> your "cut_here()" thing is a horrible hack.

What about situations where I want to print quite a lot of information, say
several lines' worth?

For instance, if you look at cachefiles_mark_object_active() in
fs/cachefiles/namei.c, you'll see something like (which extended by one of my
patches):

wait_for_old_object:
if (xobject->fscache.state < FSCACHE_OBJECT_DYING) {
unsigned keylen;
u8 *keybuf;

printk(KERN_ERR "\n");
printk(KERN_ERR "CacheFiles: Error:"
" Unexpected object collision\n");
printk(KERN_ERR "xobject: OBJ%x\n",
xobject->fscache.debug_id);
printk(KERN_ERR "xobjstate=%s\n",
fscache_object_states[xobject->fscache.state]);
printk(KERN_ERR "xobjflags=%lx\n", xobject->fscache.flags);
printk(KERN_ERR "xobjevent=%lx [%lx]\n",
xobject->fscache.events, xobject->fscache.event_mask);
printk(KERN_ERR "xops=%u inp=%u exc=%u\n",
xobject->fscache.n_ops, xobject->fscache.n_in_progress,
xobject->fscache.n_exclusive);
printk(KERN_ERR "xcookie=%p [pr=%p nd=%p fl=%lx]\n",
xobject->fscache.cookie,
xobject->fscache.cookie->parent,
xobject->fscache.cookie->netfs_data,
xobject->fscache.cookie->flags);
printk(KERN_ERR "xparent=%p\n",
xobject->fscache.parent);
printk(KERN_ERR "object: OBJ%x\n",
object->fscache.debug_id);
printk(KERN_ERR "cookie=%p [pr=%p nd=%p fl=%lx]\n",
object->fscache.cookie,
object->fscache.cookie->parent,
object->fscache.cookie->netfs_data,
object->fscache.cookie->flags);
printk(KERN_ERR "parent=%p\n",
object->fscache.parent);

keybuf = kmalloc(512, GFP_NOIO);
if (keybuf) {
struct fscache_cookie *cookie;
unsigned loop;

cookie = object->fscache.cookie;
keylen = cookie->def->get_key(cookie->netfs_data,
keybuf, 512);
printk(KERN_ERR "okey=[%u] '", keylen);
for (loop = 0; loop < keylen; loop++)
printk("%02x", keybuf[loop]);
printk("'\n");

cookie = xobject->fscache.cookie;
keylen = cookie->def->get_key(cookie->netfs_data,
keybuf, 512);
printk(KERN_ERR "xkey=[%u] '", keylen);
for (loop = 0; loop < keylen; loop++)
printk("%02x", keybuf[loop]);
printk("'\n");

kfree(keybuf);
}

BUG();

With the cut_here() approach, I could put a cut_here() just inside the if-body,
but doing it with your approach and putting the whole lot in one format string
would also be pretty horrible, and risks overrunning the printk buffer.

David

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/