From 27496a8c67bef4d789d8e3c8317ca35813a507ae Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 21 Oct 2005 03:20:48 -0400 Subject: [PATCH] gfp_t: fs/* - ->releasepage() annotated (s/int/gfp_t), instances updated - missing gfp_t in fs/* added - fixed misannotation from the original sweep caught by bitwise checks: XFS used __nocast both for gfp_t and for flags used by XFS allocator. The latter left with unsigned int __nocast; we might want to add a different type for those but for now let's leave them alone. That, BTW, is a case when __nocast use had been actively confusing - it had been used in the same code for two different and similar types, with no way to catch misuses. Switch of gfp_t to bitwise had caught that immediately... One tricky bit is left alone to be dealt with later - mapping->flags is a mix of gfp_t and error indications. Left alone for now. Signed-off-by: Al Viro Signed-off-by: Linus Torvalds --- fs/ext3/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/ext3') diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index b5177c90d6f..8b38f223279 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -1434,7 +1434,7 @@ static int ext3_invalidatepage(struct page *page, unsigned long offset) return journal_invalidatepage(journal, page, offset); } -static int ext3_releasepage(struct page *page, int wait) +static int ext3_releasepage(struct page *page, gfp_t wait) { journal_t *journal = EXT3_JOURNAL(page->mapping->host); -- cgit v1.2.3 From 6cd37cda7ed117d5a13d9b69aeded57b4fd6de14 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Fri, 28 Oct 2005 20:23:39 +0200 Subject: [PATCH] Fix ext3 warning for unused var Fix compile warning in ext3 quota code. Signed-off-by: Peter Osterlund Signed-off-by: Linus Torvalds --- fs/ext3/super.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'fs/ext3') diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 9e24ceb019f..097383c1115 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -510,19 +510,11 @@ static void ext3_clear_inode(struct inode *inode) kfree(rsv); } -static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) +static inline void ext3_show_quota_options(struct seq_file *seq, struct super_block *sb) { - struct super_block *sb = vfs->mnt_sb; +#if defined(CONFIG_QUOTA) struct ext3_sb_info *sbi = EXT3_SB(sb); - if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) - seq_puts(seq, ",data=journal"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) - seq_puts(seq, ",data=ordered"); - else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) - seq_puts(seq, ",data=writeback"); - -#if defined(CONFIG_QUOTA) if (sbi->s_jquota_fmt) seq_printf(seq, ",jqfmt=%s", (sbi->s_jquota_fmt == QFMT_VFS_OLD) ? "vfsold": "vfsv0"); @@ -539,6 +531,20 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) seq_puts(seq, ",grpquota"); #endif +} + +static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) +{ + struct super_block *sb = vfs->mnt_sb; + + if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) + seq_puts(seq, ",data=journal"); + else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA) + seq_puts(seq, ",data=ordered"); + else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA) + seq_puts(seq, ",data=writeback"); + + ext3_show_quota_options(seq, sb); return 0; } -- cgit v1.2.3 From 5b11687924e40790deb0d5f959247ade82196665 Mon Sep 17 00:00:00 2001 From: Glauber de Oliveira Costa Date: Sun, 30 Oct 2005 15:02:48 -0800 Subject: [PATCH] Locking problems while EXT3FS_DEBUG on I noticed some problems while running ext3 with the debug flag set on. More precisely, I was unable to umount the filesystem. Some investigation took me to the patch that follows. At a first glance , the lock/unlock I've taken out seems really not necessary, as the main code (outside debug) does not lock the super. The only additional danger operations that debug code introduces seems to be related to bitmap, but bitmap operations tends to be all atomic anyway. I also took the opportunity to fix 2 spelling errors. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ext3/balloc.c | 5 ++--- fs/ext3/ialloc.c | 2 -- fs/ext3/inode.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'fs/ext3') diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 0213db4911a..032c7ba1b13 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c @@ -1010,7 +1010,7 @@ retry: * allocation within the reservation window. * * This will avoid keeping on searching the reservation list again and - * again when someboday is looking for a free block (without + * again when somebody is looking for a free block (without * reservation), and there are lots of free blocks, but they are all * being reserved. * @@ -1416,12 +1416,12 @@ unsigned long ext3_count_free_blocks(struct super_block *sb) unsigned long bitmap_count, x; struct buffer_head *bitmap_bh = NULL; - lock_super(sb); es = EXT3_SB(sb)->s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; + smp_rmb(); for (i = 0; i < ngroups; i++) { gdp = ext3_get_group_desc(sb, i, NULL); if (!gdp) @@ -1440,7 +1440,6 @@ unsigned long ext3_count_free_blocks(struct super_block *sb) brelse(bitmap_bh); printk("ext3_count_free_blocks: stored = %u, computed = %lu, %lu\n", le32_to_cpu(es->s_free_blocks_count), desc_count, bitmap_count); - unlock_super(sb); return bitmap_count; #else desc_count = 0; diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 6549945f9ac..0eb4f90268d 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -704,7 +704,6 @@ unsigned long ext3_count_free_inodes (struct super_block * sb) unsigned long bitmap_count, x; struct buffer_head *bitmap_bh = NULL; - lock_super (sb); es = EXT3_SB(sb)->s_es; desc_count = 0; bitmap_count = 0; @@ -727,7 +726,6 @@ unsigned long ext3_count_free_inodes (struct super_block * sb) brelse(bitmap_bh); printk("ext3_count_free_inodes: stored = %u, computed = %lu, %lu\n", le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count); - unlock_super(sb); return desc_count; #else desc_count = 0; diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 8b38f223279..b5da5244e14 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -491,7 +491,7 @@ static unsigned long ext3_find_goal(struct inode *inode, long block, * the same format as ext3_get_branch() would do. We are calling it after * we had read the existing part of chain and partial points to the last * triple of that (one with zero ->key). Upon the exit we have the same - * picture as after the successful ext3_get_block(), excpet that in one + * picture as after the successful ext3_get_block(), except that in one * place chain is disconnected - *branch->p is still zero (we did not * set the last link), but branch->key contains the number that should * be placed into *branch->p to fill that gap. -- cgit v1.2.3 From 381be25458524f9bcec5bf1e40c82d1ebb408475 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Sun, 30 Oct 2005 15:02:56 -0800 Subject: [PATCH] ext3: sparse fixes Fix warnings from sparse due to un-declared functions that should either have a header file or have been declared static fs/ext2/bitmap.c:14:15: warning: symbol 'ext2_count_free' was not declared. Should it be static? fs/ext2/namei.c:92:15: warning: symbol 'ext2_get_parent' was not declared. Should it be static? fs/ext3/bitmap.c:15:15: warning: symbol 'ext3_count_free' was not declared. Should it be static? fs/ext3/namei.c:1013:15: warning: symbol 'ext3_get_parent' was not declared. Should it be static? fs/ext3/xattr.c:214:1: warning: symbol 'ext3_xattr_block_get' was not declared. Should it be static? fs/ext3/xattr.c:358:1: warning: symbol 'ext3_xattr_block_list' was not declared. Should it be static? fs/ext3/xattr.c:630:1: warning: symbol 'ext3_xattr_block_find' was not declared. Should it be static? fs/ext3/xattr.c:863:1: warning: symbol 'ext3_xattr_ibody_find' was not declared. Should it be static? Signed-off-by: Ben Dooks Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ext3/balloc.c | 2 ++ fs/ext3/bitmap.c | 2 +- fs/ext3/bitmap.h | 8 ++++++++ fs/ext3/ialloc.c | 1 + fs/ext3/namei.c | 2 ++ fs/ext3/namei.h | 8 ++++++++ fs/ext3/super.c | 4 +++- fs/ext3/xattr.c | 8 ++++---- 8 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 fs/ext3/bitmap.h create mode 100644 fs/ext3/namei.h (limited to 'fs/ext3') diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 032c7ba1b13..7992d21e0e0 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c @@ -20,6 +20,8 @@ #include #include +#include "bitmap.h" + /* * balloc.c contains the blocks allocation and deallocation routines */ diff --git a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c index 6c419b9ab0e..5b4ba3e246e 100644 --- a/fs/ext3/bitmap.c +++ b/fs/ext3/bitmap.c @@ -8,7 +8,7 @@ */ #include - +#include "bitmap.h" static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; diff --git a/fs/ext3/bitmap.h b/fs/ext3/bitmap.h new file mode 100644 index 00000000000..6ee503a6bb4 --- /dev/null +++ b/fs/ext3/bitmap.h @@ -0,0 +1,8 @@ +/* linux/fs/ext3/bitmap.c + * + * Copyright (C) 2005 Simtec Electronics + * Ben Dooks + * +*/ + +extern unsigned long ext3_count_free (struct buffer_head *, unsigned int ); diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 0eb4f90268d..df3f517c54a 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c @@ -26,6 +26,7 @@ #include +#include "bitmap.h" #include "xattr.h" #include "acl.h" diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 50378d8ff84..b3c690a3b54 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -36,6 +36,8 @@ #include #include #include + +#include "namei.h" #include "xattr.h" #include "acl.h" diff --git a/fs/ext3/namei.h b/fs/ext3/namei.h new file mode 100644 index 00000000000..f2ce2b0065c --- /dev/null +++ b/fs/ext3/namei.h @@ -0,0 +1,8 @@ +/* linux/fs/ext3/namei.h + * + * Copyright (C) 2005 Simtec Electronics + * Ben Dooks + * +*/ + +extern struct dentry *ext3_get_parent(struct dentry *child); diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 097383c1115..f594989ccb7 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -36,9 +36,12 @@ #include #include #include + #include + #include "xattr.h" #include "acl.h" +#include "namei.h" static int ext3_load_journal(struct super_block *, struct ext3_super_block *); static int ext3_create_journal(struct super_block *, struct ext3_super_block *, @@ -615,7 +618,6 @@ static struct super_operations ext3_sops = { #endif }; -struct dentry *ext3_get_parent(struct dentry *child); static struct export_operations ext3_export_ops = { .get_parent = ext3_get_parent, }; diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 269c7b92db9..430de9f63be 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c @@ -210,7 +210,7 @@ ext3_xattr_find_entry(struct ext3_xattr_entry **pentry, int name_index, return cmp ? -ENODATA : 0; } -int +static int ext3_xattr_block_get(struct inode *inode, int name_index, const char *name, void *buffer, size_t buffer_size) { @@ -354,7 +354,7 @@ ext3_xattr_list_entries(struct inode *inode, struct ext3_xattr_entry *entry, return buffer_size - rest; } -int +static int ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size) { struct buffer_head *bh = NULL; @@ -626,7 +626,7 @@ struct ext3_xattr_block_find { struct buffer_head *bh; }; -int +static int ext3_xattr_block_find(struct inode *inode, struct ext3_xattr_info *i, struct ext3_xattr_block_find *bs) { @@ -859,7 +859,7 @@ struct ext3_xattr_ibody_find { struct ext3_iloc iloc; }; -int +static int ext3_xattr_ibody_find(struct inode *inode, struct ext3_xattr_info *i, struct ext3_xattr_ibody_find *is) { -- cgit v1.2.3 From 2973dfdb877c17b36c27ba66d71028ff1eb2f32e Mon Sep 17 00:00:00 2001 From: Glauber de Oliveira Costa Date: Sun, 30 Oct 2005 15:03:05 -0800 Subject: [PATCH] Test for sb_getblk return value This patch adds tests for the return value of sb_getblk() in the ext2/3 filesystems. In fs/buffer.c it is stated that the getblk() function never fails. However, it does can return NULL in some situations due to I/O errors, which may lead us to NULL pointer dereferences Signed-off-by: Glauber de Oliveira Costa Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ext3/inode.c | 9 ++++++++- fs/ext3/resize.c | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'fs/ext3') diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index b5da5244e14..5d9b00e2883 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c @@ -523,7 +523,6 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, if (!nr) break; branch[n].key = cpu_to_le32(nr); - keys = n+1; /* * Get buffer_head for parent block, zero it out @@ -531,6 +530,9 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, * parent to disk. */ bh = sb_getblk(inode->i_sb, parent); + if (!bh) + break; + keys = n+1; branch[n].bh = bh; lock_buffer(bh); BUFFER_TRACE(bh, "call get_create_access"); @@ -864,6 +866,10 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode * inode, if (!*errp && buffer_mapped(&dummy)) { struct buffer_head *bh; bh = sb_getblk(inode->i_sb, dummy.b_blocknr); + if (!bh) { + *errp = -EIO; + goto err; + } if (buffer_new(&dummy)) { J_ASSERT(create != 0); J_ASSERT(handle != 0); @@ -896,6 +902,7 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode * inode, } return bh; } +err: return NULL; } diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c index 57f79106267..1be78b4b4de 100644 --- a/fs/ext3/resize.c +++ b/fs/ext3/resize.c @@ -118,6 +118,8 @@ static struct buffer_head *bclean(handle_t *handle, struct super_block *sb, int err; bh = sb_getblk(sb, blk); + if (!bh) + return ERR_PTR(-EIO); if ((err = ext3_journal_get_write_access(handle, bh))) { brelse(bh); bh = ERR_PTR(err); @@ -202,6 +204,10 @@ static int setup_new_group_blocks(struct super_block *sb, ext3_debug("update backup group %#04lx (+%d)\n", block, bit); gdb = sb_getblk(sb, block); + if (!gdb) { + err = -EIO; + goto exit_bh; + } if ((err = ext3_journal_get_write_access(handle, gdb))) { brelse(gdb); goto exit_bh; @@ -643,6 +649,10 @@ static void update_backups(struct super_block *sb, break; bh = sb_getblk(sb, group * bpg + blk_off); + if (!bh) { + err = -EIO; + break; + } ext3_debug("update metadata backup %#04lx\n", (unsigned long)bh->b_blocknr); if ((err = ext3_journal_get_write_access(handle, bh))) -- cgit v1.2.3