lkml.org 
[lkml]   [2009]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/5] FAT: notify userspace of fs errors through sysfs
Date
Report file system' errors through fs kobject's sysfs interface:
/sys/fs/fat/<part_bdev>/fs_fault.

Signed-off-by: Denis Karpov <ext-denis.2.karpov@nokia.com>
---
fs/fat/fat.h | 7 +++++++
fs/fat/inode.c | 9 +++++++++
fs/fat/misc.c | 6 ++++++
3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 1b64bae..480be11 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -72,6 +72,8 @@ struct msdos_sb_info {
int dir_per_block; /* dir entries per block */
int dir_per_block_bits; /* log2(dir_per_block) */

+ unsigned long fs_fault; /* Mark filesystem's run-time errors */
+
struct kobject s_kobj; /* kobject corresponfing to fs volume */
struct completion s_kobj_unregister;

@@ -84,6 +86,11 @@ struct msdos_sb_info {

#define FAT_CACHE_VALID 0 /* special case for valid cache */

+/* Mark FAT run-time errors */
+#define FAT_FS_FAULT_SET(sbi, val) \
+ fat_sbi_attr_set_notify(sbi, offsetof(struct msdos_sb_info, fs_fault), \
+ val)
+
/*
* MS-DOS file system inode data in memory
*/
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 61d52d1..4613343 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -527,6 +527,7 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
*flags |= MS_NODIRATIME | (sbi->options.isvfat ? 0 : MS_NOATIME);
+ FAT_FS_FAULT_SET(sbi, 0);
return 0;
}

@@ -1219,7 +1220,10 @@ static struct fat_attr fat_attr_##_name = { \

#define ATTR_LIST(name) (&fat_attr_ ##name.attr)

+FAT_SBI_RO_ATTR(fs_fault);
+
static struct attribute *fat_attrs[] = {
+ ATTR_LIST(fs_fault),
NULL
};

@@ -1565,6 +1569,11 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
init_completion(&sbi->s_kobj_unregister);
error = kobject_init_and_add(&sbi->s_kobj, &fat_ktype, NULL,
"%s", sb->s_id);
+ if (error) {
+ printk(KERN_ERR "FAT: create fs kobject failed\n");
+ goto out_fail;
+ }
+ FAT_FS_FAULT_SET(sbi, 0);

return 0;

diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index be9cb03..ce478be 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -19,6 +19,7 @@ void fat_fs_error(struct super_block *s, const char *function,
const char *fmt, ...)
{
va_list args;
+ struct msdos_sb_info *sbi = MSDOS_SB(s);

printk(KERN_ERR "FAT: Filesystem error (dev %s): %s:\n", s->s_id,
function);
@@ -33,6 +34,8 @@ void fat_fs_error(struct super_block *s, const char *function,
s->s_flags |= MS_RDONLY;
printk(KERN_ERR " File system has been set read-only\n");
}
+
+ FAT_FS_FAULT_SET(sbi, 1);
}
EXPORT_SYMBOL_GPL(fat_fs_error);

@@ -44,6 +47,7 @@ void fat_fs_warning(struct super_block *s, const char * function,
const char *fmt, ...)
{
va_list args;
+ struct msdos_sb_info *sbi = MSDOS_SB(s);

printk(KERN_ERR "FAT: Filesystem warning (dev %s): %s:\n", s->s_id,
function);
@@ -53,6 +57,8 @@ void fat_fs_warning(struct super_block *s, const char * function,
vprintk(fmt, args);
printk("\n");
va_end(args);
+
+ FAT_FS_FAULT_SET(sbi, 1);
}
EXPORT_SYMBOL_GPL(fat_fs_warning);

--
1.6.3.1


\
 
 \ /
  Last update: 2009-06-11 14:31    [W:1.912 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site