Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756422AbZFCS6y (ORCPT ); Wed, 3 Jun 2009 14:58:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753117AbZFCS6r (ORCPT ); Wed, 3 Jun 2009 14:58:47 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:58887 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752564AbZFCS6p (ORCPT ); Wed, 3 Jun 2009 14:58:45 -0400 Date: Wed, 3 Jun 2009 11:58:10 -0700 From: Andrew Morton To: Denis Karpov Cc: axboe@kernel.dk, hirofumi@mail.parknet.co.jp, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, adrian.hunter@nokia.com, artem.bityutskiy@nokia.com Subject: Re: [PATCH 1/4] FS: filesystem corruption notification Message-Id: <20090603115810.10641330.akpm@linux-foundation.org> In-Reply-To: References: <1244041518-32229-1-git-send-email-ext-denis.2.karpov@nokia.com> X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.20; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2759 Lines: 86 On Wed, 3 Jun 2009 18:05:15 +0300 Denis Karpov wrote: > Add a generic mechnism to notify the userspace about possible filesystem > corruption through sysfs entry (/sys/block///fs_unclean) > and uevent (KOBJ_CHANGE, uevent's environment variable FS_UNCLEAN=[0:1]). > > To mark fs clean (e.g. after fs was fixed by userspace): > > echo 0 > /sys/block///fs_unclean > (you will still receive uevent KOBJ_CHANGE with env var FS_UNCLEAN=0) > > Signed-off-by: Denis Karpov > --- > fs/partitions/check.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > include/linux/genhd.h | 2 ++ > 2 files changed, 44 insertions(+), 0 deletions(-) > > diff --git a/fs/partitions/check.c b/fs/partitions/check.c > index 99e33ef..191d89e 100644 > --- a/fs/partitions/check.c > +++ b/fs/partitions/check.c > @@ -196,6 +196,24 @@ check_partition(struct gendisk *hd, struct block_device *bdev) > return ERR_PTR(res); > } > > +void notify_part_fs_unclean(struct device *dev, uint8_t unclean) > +{ > + char event_string[13]; > + char *envp[] = { event_string, NULL }; > + > + if ((unclean != 0 && unclean != 1) || > + unclean == dev_to_part(dev)->fs_unclean) > + return; > + > + dev_to_part(dev)->fs_unclean = unclean; > + > + sysfs_notify(&dev->kobj, NULL, "fs_unclean"); > + > + sprintf(event_string, "FS_UNCLEAN=%u", unclean); > + kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); > +} > +EXPORT_SYMBOL(notify_part_fs_unclean); Please document this function. That documentation should, amongst other things, explain the semantics of the `unclean' argument. It can be 0, 1 or "something else". Why? Also, why is `unclean' a u8 rather than a boring old `int'? > static ssize_t part_partition_show(struct device *dev, > struct device_attribute *attr, char *buf) > { > @@ -246,6 +264,26 @@ ssize_t part_stat_show(struct device *dev, > jiffies_to_msecs(part_stat_read(p, time_in_queue))); > } > > +ssize_t part_fs_unclean_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct hd_struct *p = dev_to_part(dev); > + > + return sprintf(buf, "%d\n", p->fs_unclean); > +} > + > +ssize_t part_fs_unclean_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + int i; > + > + if (count > 0 && sscanf(buf, "%d", &i) > 0) strict_strtoul(), please. > + notify_part_fs_unclean(dev, (i == 0) ? 0 : 1); > + > + return count; > +} -- 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/