Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Thu, 21 Nov 2002 18:00:50 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Thu, 21 Nov 2002 18:00:49 -0500 Received: from air-2.osdl.org ([65.172.181.6]:49795 "EHLO mail.osdl.org") by vger.kernel.org with ESMTP id ; Thu, 21 Nov 2002 18:00:31 -0500 Date: Thu, 21 Nov 2002 17:03:44 -0600 (CST) From: Patrick Mochel X-X-Sender: To: Rusty Lynch cc: Linux Kernel Mailing List Subject: Re: [BUG] sysfs on 2.5.48 unable to remove files while in use In-Reply-To: <003701c291aa$a3b28a10$94d40a0a@amr.corp.intel.com> Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-973767115-1037919824=:913" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 20248 Lines: 521 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --8323328-973767115-1037919824=:913 Content-Type: TEXT/PLAIN; charset=US-ASCII > Very cool. Bitkeeper is one of those things I never bothered > with yet (mainly because I feel some comfortable with CVS.) > It looks like it might be worth going through ramp-up time > on bk to keep up with changes to the kernel. There are also nightly snapshots, though I don't recall the URL off the top of my head.. > > It seems that having a pure sysfs implementation would be superior, > > instead of having to use a character device to write to. After looking > > into this, I realize that a couple of pieces of infrastructure are needed, > > so I'm working on that, and will post a modified version of your module > > once I'm done.. > > I look forward to seeing it. Ok, there are basically two parts to it: the required modifications to sysfs and your updated module. The appended patch adds the support to sysfs be defining struct subsys_attribute for declaring attributes of subsystems themselves, as well as the needed helpers for creation/teardown and read/write. I've attached a replacement for noisy.c that creates a sysfs file named 'ctl' that handles addition and deletion of nprobes, similar to the char device you had created. From the top of the file: /* * Noisy Interface for Linux * * This driver allows arbitrary printk's to be inserted into * executing kernel code by using the new kprobes interface. * A message is attached to an address, and when that address * is reached, the message is printed. * * This uses a sysfs control file to manage a list of probes. * The sysfs directory is at * * /sys/noisy/ * * and the control is named 'ctl'. * * A Noisy Probe can be added by echoing into the file, like: * * $ echo "add
" > /sys/noisy/ctl * * where
is the address to break on, and * is the message to print when the address is reached. * * Probes can be removed by doing: * * $ echo "del
" > /sys/noisy/ctl * * where
is the address of the probe. * * The probes themselves get a directory under /sys/noisy/, and * the name of the directory is the address of the probe. Each * probe directory contains one file ('message') that contains * the message to be printed. (More may be added later). */ I've tried to comment the changes and the necessary steps in making this work. [ Note: While I'm generally happy with the way things work, I realize that it still requires a decent amount of overhead in using the sysfs interface (see the file). I'll be looking into shrinking this...] Everything seems to work.. > It looks like the patch is against the bk tree, and does not apply cleanly > to > strait 2.5.48. I don't know how much has changed to sysfs/inode.c, but > I can see where the last hunk is looking too far up, so I'll try it anyway. Ah yes, I forgot there was a patch applied to sysfs since 2.5.48. I've included everything since 2.5.48 in the one I've appended. -pat ===== fs/sysfs/inode.c 1.60 vs 1.67 ===== --- 1.60/fs/sysfs/inode.c Sat Nov 16 15:01:34 2002 +++ 1.67/fs/sysfs/inode.c Thu Nov 21 17:01:53 2002 @@ -23,6 +23,8 @@ * Please see Documentation/filesystems/sysfs.txt for more information. */ +#undef DEBUG + #include #include #include @@ -87,16 +89,17 @@ return inode; } -static int sysfs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev) +static int sysfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { struct inode *inode; int error = 0; if (!dentry->d_inode) { inode = sysfs_get_inode(dir->i_sb, mode, dev); - if (inode) + if (inode) { d_instantiate(dentry, inode); - else + dget(dentry); + } else error = -ENOSPC; } else error = -EEXIST; @@ -142,17 +145,43 @@ return error; } -static int sysfs_unlink(struct inode *dir, struct dentry *dentry) +#define to_subsys(k) container_of(k,struct subsystem,kobj) +#define to_sattr(a) container_of(a,struct subsys_attribute,attr) + +/** + * Subsystem file operations. + * These operations allow subsystems to have files that can be + * read/written. + */ +ssize_t subsys_attr_show(struct kobject * kobj, struct attribute * attr, + char * page, size_t count, loff_t off) { - struct inode *inode = dentry->d_inode; - down(&inode->i_sem); - dentry->d_inode->i_nlink--; - up(&inode->i_sem); - d_invalidate(dentry); - dput(dentry); - return 0; + struct subsystem * s = to_subsys(kobj); + struct subsys_attribute * sattr = to_sattr(attr); + ssize_t ret = 0; + + if (sattr->show) + ret = sattr->show(s,page,count,off); + return ret; } +ssize_t subsys_attr_store(struct kobject * kobj, struct attribute * attr, + const char * page, size_t count, loff_t off) +{ + struct subsystem * s = to_subsys(kobj); + struct subsys_attribute * sattr = to_sattr(attr); + ssize_t ret = 0; + + if (sattr->store) + ret = sattr->store(s,page,count,off); + return ret; +} + +static struct sysfs_ops subsys_sysfs_ops = { + .show = subsys_attr_show, + .store = subsys_attr_store, +}; + /** * sysfs_read_file - read an attribute. * @file: file pointer. @@ -173,17 +202,11 @@ sysfs_read_file(struct file *file, char *buf, size_t count, loff_t *ppos) { struct attribute * attr = file->f_dentry->d_fsdata; - struct sysfs_ops * ops = NULL; - struct kobject * kobj; + struct sysfs_ops * ops = file->private_data; + struct kobject * kobj = file->f_dentry->d_parent->d_fsdata; unsigned char *page; ssize_t retval = 0; - kobj = file->f_dentry->d_parent->d_fsdata; - if (kobj && kobj->subsys) - ops = kobj->subsys->sysfs_ops; - if (!ops || !ops->show) - return 0; - if (count > PAGE_SIZE) count = PAGE_SIZE; @@ -234,16 +257,11 @@ sysfs_write_file(struct file *file, const char *buf, size_t count, loff_t *ppos) { struct attribute * attr = file->f_dentry->d_fsdata; - struct sysfs_ops * ops = NULL; - struct kobject * kobj; + struct sysfs_ops * ops = file->private_data; + struct kobject * kobj = file->f_dentry->d_parent->d_fsdata; ssize_t retval = 0; char * page; - kobj = file->f_dentry->d_parent->d_fsdata; - if (kobj && kobj->subsys) - ops = kobj->subsys->sysfs_ops; - if (!ops || !ops->store) - return 0; page = (char *)__get_free_page(GFP_KERNEL); if (!page) @@ -275,21 +293,77 @@ return retval; } -static int sysfs_open_file(struct inode * inode, struct file * filp) +static int check_perm(struct inode * inode, struct file * file) { - struct kobject * kobj; + struct kobject * kobj = kobject_get(file->f_dentry->d_parent->d_fsdata); + struct attribute * attr = file->f_dentry->d_fsdata; + struct sysfs_ops * ops = NULL; int error = 0; - kobj = filp->f_dentry->d_parent->d_fsdata; - if ((kobj = kobject_get(kobj))) { - struct attribute * attr = filp->f_dentry->d_fsdata; - if (!attr) - error = -EINVAL; - } else - error = -EINVAL; + if (!kobj || !attr) + goto Einval; + + /* if the kobject has no subsystem, then it is a subsystem itself, + * so give it the subsys_sysfs_ops. + */ + if (kobj->subsys) + ops = kobj->subsys->sysfs_ops; + else + ops = &subsys_sysfs_ops; + + /* No sysfs operations, either from having no subsystem, + * or the subsystem have no operations. + */ + if (!ops) + goto Eaccess; + + /* File needs write support. + * The inode's perms must say it's ok, + * and we must have a store method. + */ + if (file->f_mode & FMODE_WRITE) { + + if (!(inode->i_mode & S_IWUGO)) + goto Eperm; + if (!ops->store) + goto Eaccess; + + } + + /* File needs read support. + * The inode's perms must say it's ok, and we there + * must be a show method for it. + */ + if (file->f_mode & FMODE_READ) { + if (!(inode->i_mode & S_IRUGO)) + goto Eperm; + if (!ops->show) + goto Eaccess; + } + + /* No error? Great, store the ops in file->private_data + * for easy access in the read/write functions. + */ + file->private_data = ops; + goto Done; + + Einval: + error = -EINVAL; + goto Done; + Eaccess: + error = -EACCES; + goto Done; + Eperm: + error = -EPERM; + Done: return error; } +static int sysfs_open_file(struct inode * inode, struct file * filp) +{ + return check_perm(inode,filp); +} + static int sysfs_release(struct inode * inode, struct file * filp) { struct kobject * kobj = filp->f_dentry->d_parent->d_fsdata; @@ -541,7 +615,8 @@ /* make sure dentry is really there */ if (victim->d_inode && (victim->d_parent->d_inode == dir->d_inode)) { - sysfs_unlink(dir->d_inode,victim); + simple_unlink(dir->d_inode,victim); + d_delete(victim); } } up(&dir->d_inode->i_sem); @@ -599,19 +674,16 @@ list_for_each_safe(node,next,&dentry->d_subdirs) { struct dentry * d = list_entry(node,struct dentry,d_child); /* make sure dentry is still there */ - if (d->d_inode) - sysfs_unlink(dentry->d_inode,d); + if (d->d_inode) { + simple_unlink(dentry->d_inode,d); + d_delete(dentry); + } } - d_invalidate(dentry); - if (simple_empty(dentry)) { - dentry->d_inode->i_nlink -= 2; - dentry->d_inode->i_flags |= S_DEAD; - parent->d_inode->i_nlink--; - } up(&dentry->d_inode->i_sem); - dput(dentry); - + d_invalidate(dentry); + simple_rmdir(parent->d_inode,dentry); + d_delete(dentry); up(&parent->d_inode->i_sem); dput(parent); } @@ -622,4 +694,3 @@ EXPORT_SYMBOL(sysfs_remove_link); EXPORT_SYMBOL(sysfs_create_dir); EXPORT_SYMBOL(sysfs_remove_dir); -MODULE_LICENSE("GPL"); --8323328-973767115-1037919824=:913 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="noisy.c" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="noisy.c" LyoNCiAqIE5vaXN5IEludGVyZmFjZSBmb3IgTGludXgNCiAqDQogKiBUaGlz IGRyaXZlciBhbGxvd3MgYXJiaXRyYXJ5IHByaW50aydzIHRvIGJlIGluc2Vy dGVkIGludG8NCiAqIGV4ZWN1dGluZyBrZXJuZWwgY29kZSBieSB1c2luZyB0 aGUgbmV3IGtwcm9iZXMgaW50ZXJmYWNlLg0KICogQSBtZXNzYWdlIGlzIGF0 dGFjaGVkIHRvIGFuIGFkZHJlc3MsIGFuZCB3aGVuIHRoYXQgYWRkcmVzcw0K ICogaXMgcmVhY2hlZCwgdGhlIG1lc3NhZ2UgaXMgcHJpbnRlZC4gDQogKg0K ICogVGhpcyB1c2VzIGEgc3lzZnMgY29udHJvbCBmaWxlIHRvIG1hbmFnZSBh IGxpc3Qgb2YgcHJvYmVzLiANCiAqIFRoZSBzeXNmcyBkaXJlY3RvcnkgaXMg YXQNCiAqDQogKiAvc3lzL25vaXN5Lw0KICoNCiAqIGFuZCB0aGUgY29udHJv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vciA9IGRl bChhZGRyKTsNCgllbHNlDQoJCWVycm9yID0gLUVJTlZBTDsNCglyZXQgPSBl cnJvciA/IGVycm9yIDogY291bnQ7DQogRG9uZToNCgl1cCgmbm9pc3lfc2Vt KTsNCglyZXR1cm4gcmV0Ow0KfQ0KDQpzdGF0aWMgc3RydWN0IHN1YnN5c19h dHRyaWJ1dGUgc3Vic3lzX2F0dHJfY3RsID0gew0KCS5hdHRyCT0geyAubmFt ZSA9ICJjdGwiLCAubW9kZSA9IDA2NDQgfSwNCgkuc2hvdwk9IGN0bF9zaG93 LA0KCS5zdG9yZQk9IGN0bF9zdG9yZSwNCn07DQoNCg0Kc3RhdGljIGludCBf X2luaXQgbm9pc3lfaW5pdCh2b2lkKQ0Kew0KCXN1YnN5c3RlbV9yZWdpc3Rl cigmbm9pc3lfc3Vic3lzKTsNCglzdWJzeXNfY3JlYXRlX2ZpbGUoJm5vaXN5 X3N1YnN5cywmc3Vic3lzX2F0dHJfY3RsKTsNCglyZXR1cm4gMDsNCn0NCg0K c3RhdGljIHZvaWQgX19leGl0IG5vaXN5X2V4aXQgKHZvaWQpDQp7DQoJc3Vi c3lzX3JlbW92ZV9maWxlKCZub2lzeV9zdWJzeXMsJnN1YnN5c19hdHRyX2N0 bCk7DQoJc3Vic3lzdGVtX3VucmVnaXN0ZXIoJm5vaXN5X3N1YnN5cyk7DQp9 DQoNCm1vZHVsZV9pbml0KG5vaXN5X2luaXQpOw0KbW9kdWxlX2V4aXQobm9p c3lfZXhpdCk7DQoNCk1PRFVMRV9BVVRIT1IoIlJ1c3R5IEx5bmNoIik7DQpN T0RVTEVfTElDRU5TRSgiR1BMIik7DQo= --8323328-973767115-1037919824=:913-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/