From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric W. Biederman" Subject: [PATCH 05/26] sysfs: Improve sysfs directory deletion debugging. Date: Fri, 29 May 2009 13:19:15 -0700 Message-ID: <1243628376-22905-5-git-send-email-ebiederm@xmission.com> References: Cc: , Tejun Heo , Cornelia Huck , , Kay Sievers , Greg KH , "Eric W. Biederman" , "Eric W. Biederman" To: Andrew Morton , Greg Kroah-Hartman Return-path: Received: from out01.mta.xmission.com ([166.70.13.231]:41741 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761516AbZE2UTx (ORCPT ); Fri, 29 May 2009 16:19:53 -0400 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Eric W. Biederman We have found several cases where directories are deleted without removing all of their subdirectories. That case isn't valid so warn anyone who makes that mistake, and continue to leak dirents to keep the system as operational as possible. Move the debug message when a directory is deleted into remove_dir so we are told when subdirectories are deleted as well as full fledge kobject directories. Signed-off-by: Eric W. Biederman --- fs/sysfs/dir.c | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index a55e1d4..60482be 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -732,12 +732,28 @@ const struct inode_operations sysfs_dir_inode_operations = { .setattr = sysfs_setattr, }; -static void remove_dir(struct sysfs_dirent *sd) +static void remove_dir(struct sysfs_dirent *dir_sd) { struct sysfs_addrm_cxt acxt; - sysfs_addrm_start(&acxt, sd->s_parent); - sysfs_remove_one(&acxt, sd); + pr_debug("sysfs %s: removing dir\n", dir_sd->s_name); + + /* Removing non-empty directories is not valid complain! */ + if (unlikely(dir_sd->s_dir.children)) { + struct sysfs_dirent *sd; + + WARN(1, KERN_WARNING "sysfs: removing non-empty dir: %s\n", + dir_sd->s_name); + + mutex_lock(&sysfs_mutex); + for (sd = dir_sd->s_dir.children; sd; sd = sd->s_sibling) + printk(KERN_WARNING "%s/%s\n", + dir_sd->s_name, sd->s_name); + mutex_unlock(&sysfs_mutex); + } + + sysfs_addrm_start(&acxt, dir_sd->s_parent); + sysfs_remove_one(&acxt, dir_sd); sysfs_addrm_finish(&acxt); } @@ -752,7 +768,6 @@ static void __sysfs_remove_dir(struct sysfs_dirent *dir_sd) struct sysfs_addrm_cxt acxt; struct sysfs_dirent **pos; - pr_debug("sysfs %s: removing dir\n", dir_sd->s_name); sysfs_addrm_start(&acxt, dir_sd); pos = &dir_sd->s_dir.children; while (*pos) { -- 1.6.3.1.54.g99dd.dirty