aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 20:59:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 20:59:17 -0400
commita7963eb7f4c4b5df84d5dd5083734278ad75bafb (patch)
tree65ac1402e20651b9fc59207480bac8399a30771e
parentb003d7706abc5d75cb58de0c9de8f1fc77e57008 (diff)
parent01d8885785a60ae8f4c37b0ed75bdc96d0fc6a44 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext3 improvements, cleanups, reiserfs fix from Jan Kara: "various cleanups for ext2, ext3, udf, isofs, a documentation update for quota, and a fix of a race in reiserfs readdir implementation" * 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs: reiserfs: fix race in readdir ext2: acl: remove unneeded include of linux/capability.h ext3: explicitly remove inode from orphan list after failed direct io fs/isofs/inode.c add __init to init_inodecache() ext3: Speedup WB_SYNC_ALL pass fs/quota/Kconfig: Update filesystems ext3: Update outdated comment before ext3_ordered_writepage() ext3: Update PF_MEMALLOC handling in ext3_write_inode() ext2/3: use prandom_u32() instead of get_random_bytes() ext3: remove an unneeded check in ext3_new_blocks() ext3: remove unneeded check in ext3_ordered_writepage() fs: Mark function as static in ext3/xattr_security.c fs: Mark function as static in ext3/dir.c fs: Mark function as static in ext2/xattr_security.c ext3: Add __init macro to init_inodecache ext2: Add __init macro to init_inodecache udf: Add __init macro to init_inodecache fs: udf: parse_options: blocksize check
-rw-r--r--fs/ext2/acl.c1
-rw-r--r--fs/ext2/ialloc.c2
-rw-r--r--fs/ext2/super.c2
-rw-r--r--fs/ext2/xattr_security.c4
-rw-r--r--fs/ext3/balloc.c5
-rw-r--r--fs/ext3/dir.c2
-rw-r--r--fs/ext3/ialloc.c2
-rw-r--r--fs/ext3/inode.c86
-rw-r--r--fs/ext3/super.c2
-rw-r--r--fs/ext3/xattr_security.c5
-rw-r--r--fs/isofs/inode.c2
-rw-r--r--fs/quota/Kconfig7
-rw-r--r--fs/reiserfs/dir.c6
-rw-r--r--fs/udf/super.c8
14 files changed, 51 insertions, 83 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 1b8001bbe947..27695e6f4e46 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -4,7 +4,6 @@
4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> 4 * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
5 */ 5 */
6 6
7#include <linux/capability.h>
8#include <linux/init.h> 7#include <linux/init.h>
9#include <linux/sched.h> 8#include <linux/sched.h>
10#include <linux/slab.h> 9#include <linux/slab.h>
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 7cadd823bb31..7d66fb0e4cca 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -284,7 +284,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
284 int best_ndir = inodes_per_group; 284 int best_ndir = inodes_per_group;
285 int best_group = -1; 285 int best_group = -1;
286 286
287 get_random_bytes(&group, sizeof(group)); 287 group = prandom_u32();
288 parent_group = (unsigned)group % ngroups; 288 parent_group = (unsigned)group % ngroups;
289 for (i = 0; i < ngroups; i++) { 289 for (i = 0; i < ngroups; i++) {
290 group = (parent_group + i) % ngroups; 290 group = (parent_group + i) % ngroups;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index d260115c0350..3750031cfa2f 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -192,7 +192,7 @@ static void init_once(void *foo)
192 inode_init_once(&ei->vfs_inode); 192 inode_init_once(&ei->vfs_inode);
193} 193}
194 194
195static int init_inodecache(void) 195static int __init init_inodecache(void)
196{ 196{
197 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache", 197 ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
198 sizeof(struct ext2_inode_info), 198 sizeof(struct ext2_inode_info),
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
index cfedb2cb0d8c..c0ebc4db8849 100644
--- a/fs/ext2/xattr_security.c
+++ b/fs/ext2/xattr_security.c
@@ -42,8 +42,8 @@ ext2_xattr_security_set(struct dentry *dentry, const char *name,
42 value, size, flags); 42 value, size, flags);
43} 43}
44 44
45int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array, 45static int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
46 void *fs_info) 46 void *fs_info)
47{ 47{
48 const struct xattr *xattr; 48 const struct xattr *xattr;
49 int err = 0; 49 int err = 0;
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 22548f56197b..158b5d4ce067 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1727,10 +1727,7 @@ allocated:
1727 percpu_counter_sub(&sbi->s_freeblocks_counter, num); 1727 percpu_counter_sub(&sbi->s_freeblocks_counter, num);
1728 1728
1729 BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor"); 1729 BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
1730 err = ext3_journal_dirty_metadata(handle, gdp_bh); 1730 fatal = ext3_journal_dirty_metadata(handle, gdp_bh);
1731 if (!fatal)
1732 fatal = err;
1733
1734 if (fatal) 1731 if (fatal)
1735 goto out; 1732 goto out;
1736 1733
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index e66e4808719f..17742eed2c16 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -275,7 +275,7 @@ static inline loff_t ext3_get_htree_eof(struct file *filp)
275 * NOTE: offsets obtained *before* ext3_set_inode_flag(dir, EXT3_INODE_INDEX) 275 * NOTE: offsets obtained *before* ext3_set_inode_flag(dir, EXT3_INODE_INDEX)
276 * will be invalid once the directory was converted into a dx directory 276 * will be invalid once the directory was converted into a dx directory
277 */ 277 */
278loff_t ext3_dir_llseek(struct file *file, loff_t offset, int whence) 278static loff_t ext3_dir_llseek(struct file *file, loff_t offset, int whence)
279{ 279{
280 struct inode *inode = file->f_mapping->host; 280 struct inode *inode = file->f_mapping->host;
281 int dx_dir = is_dx_dir(inode); 281 int dx_dir = is_dx_dir(inode);
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 082afd78b107..a1b810230cc5 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -215,7 +215,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
215 int best_ndir = inodes_per_group; 215 int best_ndir = inodes_per_group;
216 int best_group = -1; 216 int best_group = -1;
217 217
218 get_random_bytes(&group, sizeof(group)); 218 group = prandom_u32();
219 parent_group = (unsigned)group % ngroups; 219 parent_group = (unsigned)group % ngroups;
220 for (i = 0; i < ngroups; i++) { 220 for (i = 0; i < ngroups; i++) {
221 group = (parent_group + i) % ngroups; 221 group = (parent_group + i) % ngroups;
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index efce2bbfb5e5..f5157d0d1b43 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1559,56 +1559,17 @@ static int buffer_unmapped(handle_t *handle, struct buffer_head *bh)
1559} 1559}
1560 1560
1561/* 1561/*
1562 * Note that we always start a transaction even if we're not journalling 1562 * Note that whenever we need to map blocks we start a transaction even if
1563 * data. This is to preserve ordering: any hole instantiation within 1563 * we're not journalling data. This is to preserve ordering: any hole
1564 * __block_write_full_page -> ext3_get_block() should be journalled 1564 * instantiation within __block_write_full_page -> ext3_get_block() should be
1565 * along with the data so we don't crash and then get metadata which 1565 * journalled along with the data so we don't crash and then get metadata which
1566 * refers to old data. 1566 * refers to old data.
1567 * 1567 *
1568 * In all journalling modes block_write_full_page() will start the I/O. 1568 * In all journalling modes block_write_full_page() will start the I/O.
1569 * 1569 *
1570 * Problem:
1571 *
1572 * ext3_writepage() -> kmalloc() -> __alloc_pages() -> page_launder() ->
1573 * ext3_writepage()
1574 *
1575 * Similar for:
1576 *
1577 * ext3_file_write() -> generic_file_write() -> __alloc_pages() -> ...
1578 *
1579 * Same applies to ext3_get_block(). We will deadlock on various things like
1580 * lock_journal and i_truncate_mutex.
1581 *
1582 * Setting PF_MEMALLOC here doesn't work - too many internal memory
1583 * allocations fail.
1584 *
1585 * 16May01: If we're reentered then journal_current_handle() will be
1586 * non-zero. We simply *return*.
1587 *
1588 * 1 July 2001: @@@ FIXME:
1589 * In journalled data mode, a data buffer may be metadata against the
1590 * current transaction. But the same file is part of a shared mapping
1591 * and someone does a writepage() on it.
1592 *
1593 * We will move the buffer onto the async_data list, but *after* it has
1594 * been dirtied. So there's a small window where we have dirty data on
1595 * BJ_Metadata.
1596 *
1597 * Note that this only applies to the last partial page in the file. The
1598 * bit which block_write_full_page() uses prepare/commit for. (That's
1599 * broken code anyway: it's wrong for msync()).
1600 *
1601 * It's a rare case: affects the final partial page, for journalled data
1602 * where the file is subject to bith write() and writepage() in the same
1603 * transction. To fix it we'll need a custom block_write_full_page().
1604 * We'll probably need that anyway for journalling writepage() output.
1605 *
1606 * We don't honour synchronous mounts for writepage(). That would be 1570 * We don't honour synchronous mounts for writepage(). That would be
1607 * disastrous. Any write() or metadata operation will sync the fs for 1571 * disastrous. Any write() or metadata operation will sync the fs for
1608 * us. 1572 * us.
1609 *
1610 * AKPM2: if all the page's buffers are mapped to disk and !data=journal,
1611 * we don't need to open a transaction here.
1612 */ 1573 */
1613static int ext3_ordered_writepage(struct page *page, 1574static int ext3_ordered_writepage(struct page *page,
1614 struct writeback_control *wbc) 1575 struct writeback_control *wbc)
@@ -1673,12 +1634,9 @@ static int ext3_ordered_writepage(struct page *page,
1673 * block_write_full_page() succeeded. Otherwise they are unmapped, 1634 * block_write_full_page() succeeded. Otherwise they are unmapped,
1674 * and generally junk. 1635 * and generally junk.
1675 */ 1636 */
1676 if (ret == 0) { 1637 if (ret == 0)
1677 err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE, 1638 ret = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
1678 NULL, journal_dirty_data_fn); 1639 NULL, journal_dirty_data_fn);
1679 if (!ret)
1680 ret = err;
1681 }
1682 walk_page_buffers(handle, page_bufs, 0, 1640 walk_page_buffers(handle, page_bufs, 0,
1683 PAGE_CACHE_SIZE, NULL, bput_one); 1641 PAGE_CACHE_SIZE, NULL, bput_one);
1684 err = ext3_journal_stop(handle); 1642 err = ext3_journal_stop(handle);
@@ -1925,6 +1883,8 @@ retry:
1925 * and pretend the write failed... */ 1883 * and pretend the write failed... */
1926 ext3_truncate_failed_direct_write(inode); 1884 ext3_truncate_failed_direct_write(inode);
1927 ret = PTR_ERR(handle); 1885 ret = PTR_ERR(handle);
1886 if (inode->i_nlink)
1887 ext3_orphan_del(NULL, inode);
1928 goto out; 1888 goto out;
1929 } 1889 }
1930 if (inode->i_nlink) 1890 if (inode->i_nlink)
@@ -3212,21 +3172,20 @@ out_brelse:
3212 * 3172 *
3213 * We are called from a few places: 3173 * We are called from a few places:
3214 * 3174 *
3215 * - Within generic_file_write() for O_SYNC files. 3175 * - Within generic_file_aio_write() -> generic_write_sync() for O_SYNC files.
3216 * Here, there will be no transaction running. We wait for any running 3176 * Here, there will be no transaction running. We wait for any running
3217 * transaction to commit. 3177 * transaction to commit.
3218 * 3178 *
3219 * - Within sys_sync(), kupdate and such. 3179 * - Within flush work (for sys_sync(), kupdate and such).
3220 * We wait on commit, if tol to. 3180 * We wait on commit, if told to.
3221 * 3181 *
3222 * - Within prune_icache() (PF_MEMALLOC == true) 3182 * - Within iput_final() -> write_inode_now()
3223 * Here we simply return. We can't afford to block kswapd on the 3183 * We wait on commit, if told to.
3224 * journal commit.
3225 * 3184 *
3226 * In all cases it is actually safe for us to return without doing anything, 3185 * In all cases it is actually safe for us to return without doing anything,
3227 * because the inode has been copied into a raw inode buffer in 3186 * because the inode has been copied into a raw inode buffer in
3228 * ext3_mark_inode_dirty(). This is a correctness thing for O_SYNC and for 3187 * ext3_mark_inode_dirty(). This is a correctness thing for WB_SYNC_ALL
3229 * knfsd. 3188 * writeback.
3230 * 3189 *
3231 * Note that we are absolutely dependent upon all inode dirtiers doing the 3190 * Note that we are absolutely dependent upon all inode dirtiers doing the
3232 * right thing: they *must* call mark_inode_dirty() after dirtying info in 3191 * right thing: they *must* call mark_inode_dirty() after dirtying info in
@@ -3238,13 +3197,13 @@ out_brelse:
3238 * stuff(); 3197 * stuff();
3239 * inode->i_size = expr; 3198 * inode->i_size = expr;
3240 * 3199 *
3241 * is in error because a kswapd-driven write_inode() could occur while 3200 * is in error because write_inode() could occur while `stuff()' is running,
3242 * `stuff()' is running, and the new i_size will be lost. Plus the inode 3201 * and the new i_size will be lost. Plus the inode will no longer be on the
3243 * will no longer be on the superblock's dirty inode list. 3202 * superblock's dirty inode list.
3244 */ 3203 */
3245int ext3_write_inode(struct inode *inode, struct writeback_control *wbc) 3204int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
3246{ 3205{
3247 if (current->flags & PF_MEMALLOC) 3206 if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
3248 return 0; 3207 return 0;
3249 3208
3250 if (ext3_journal_current_handle()) { 3209 if (ext3_journal_current_handle()) {
@@ -3253,7 +3212,12 @@ int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
3253 return -EIO; 3212 return -EIO;
3254 } 3213 }
3255 3214
3256 if (wbc->sync_mode != WB_SYNC_ALL) 3215 /*
3216 * No need to force transaction in WB_SYNC_NONE mode. Also
3217 * ext3_sync_fs() will force the commit after everything is
3218 * written.
3219 */
3220 if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync)
3257 return 0; 3221 return 0;
3258 3222
3259 return ext3_force_commit(inode->i_sb); 3223 return ext3_force_commit(inode->i_sb);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 95c6c5a6d0c5..08cdfe5461e3 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -527,7 +527,7 @@ static void init_once(void *foo)
527 inode_init_once(&ei->vfs_inode); 527 inode_init_once(&ei->vfs_inode);
528} 528}
529 529
530static int init_inodecache(void) 530static int __init init_inodecache(void)
531{ 531{
532 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", 532 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",
533 sizeof(struct ext3_inode_info), 533 sizeof(struct ext3_inode_info),
diff --git a/fs/ext3/xattr_security.c b/fs/ext3/xattr_security.c
index 3387664ad70e..722c2bf9645d 100644
--- a/fs/ext3/xattr_security.c
+++ b/fs/ext3/xattr_security.c
@@ -43,8 +43,9 @@ ext3_xattr_security_set(struct dentry *dentry, const char *name,
43 name, value, size, flags); 43 name, value, size, flags);
44} 44}
45 45
46int ext3_initxattrs(struct inode *inode, const struct xattr *xattr_array, 46static int ext3_initxattrs(struct inode *inode,
47 void *fs_info) 47 const struct xattr *xattr_array,
48 void *fs_info)
48{ 49{
49 const struct xattr *xattr; 50 const struct xattr *xattr;
50 handle_t *handle = fs_info; 51 handle_t *handle = fs_info;
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 6af66ee56390..4556ce1af5b0 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -93,7 +93,7 @@ static void init_once(void *foo)
93 inode_init_once(&ei->vfs_inode); 93 inode_init_once(&ei->vfs_inode);
94} 94}
95 95
96static int init_inodecache(void) 96static int __init init_inodecache(void)
97{ 97{
98 isofs_inode_cachep = kmem_cache_create("isofs_inode_cache", 98 isofs_inode_cachep = kmem_cache_create("isofs_inode_cache",
99 sizeof(struct iso_inode_info), 99 sizeof(struct iso_inode_info),
diff --git a/fs/quota/Kconfig b/fs/quota/Kconfig
index 880fd9884366..c51df1dd237e 100644
--- a/fs/quota/Kconfig
+++ b/fs/quota/Kconfig
@@ -8,9 +8,10 @@ config QUOTA
8 help 8 help
9 If you say Y here, you will be able to set per user limits for disk 9 If you say Y here, you will be able to set per user limits for disk
10 usage (also called disk quotas). Currently, it works for the 10 usage (also called disk quotas). Currently, it works for the
11 ext2, ext3, and reiserfs file system. ext3 also supports journalled 11 ext2, ext3, ext4, jfs, ocfs2 and reiserfs file systems.
12 quotas for which you don't need to run quotacheck(8) after an unclean 12 Note that gfs2 and xfs use their own quota system.
13 shutdown. 13 Ext3, ext4 and reiserfs also support journaled quotas for which
14 you don't need to run quotacheck(8) after an unclean shutdown.
14 For further details, read the Quota mini-HOWTO, available from 15 For further details, read the Quota mini-HOWTO, available from
15 <http://www.tldp.org/docs.html#howto>, or the documentation provided 16 <http://www.tldp.org/docs.html#howto>, or the documentation provided
16 with the quota tools. Probably the quota support is only useful for 17 with the quota tools. Probably the quota support is only useful for
diff --git a/fs/reiserfs/dir.c b/fs/reiserfs/dir.c
index 1fd2051109a3..af677353a3f5 100644
--- a/fs/reiserfs/dir.c
+++ b/fs/reiserfs/dir.c
@@ -125,6 +125,7 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
125 int d_reclen; 125 int d_reclen;
126 char *d_name; 126 char *d_name;
127 ino_t d_ino; 127 ino_t d_ino;
128 loff_t cur_pos = deh_offset(deh);
128 129
129 if (!de_visible(deh)) 130 if (!de_visible(deh))
130 /* it is hidden entry */ 131 /* it is hidden entry */
@@ -196,8 +197,9 @@ int reiserfs_readdir_inode(struct inode *inode, struct dir_context *ctx)
196 if (local_buf != small_buf) { 197 if (local_buf != small_buf) {
197 kfree(local_buf); 198 kfree(local_buf);
198 } 199 }
199 // next entry should be looked for with such offset 200
200 next_pos = deh_offset(deh) + 1; 201 /* deh_offset(deh) may be invalid now. */
202 next_pos = cur_pos + 1;
201 203
202 if (item_moved(&tmp_ih, &path_to_entry)) { 204 if (item_moved(&tmp_ih, &path_to_entry)) {
203 set_cpu_key_k_offset(&pos_key, 205 set_cpu_key_k_offset(&pos_key,
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 64f2b7334d08..3286db047a40 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -175,7 +175,7 @@ static void init_once(void *foo)
175 inode_init_once(&ei->vfs_inode); 175 inode_init_once(&ei->vfs_inode);
176} 176}
177 177
178static int init_inodecache(void) 178static int __init init_inodecache(void)
179{ 179{
180 udf_inode_cachep = kmem_cache_create("udf_inode_cache", 180 udf_inode_cachep = kmem_cache_create("udf_inode_cache",
181 sizeof(struct udf_inode_info), 181 sizeof(struct udf_inode_info),
@@ -505,6 +505,7 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
505 while ((p = strsep(&options, ",")) != NULL) { 505 while ((p = strsep(&options, ",")) != NULL) {
506 substring_t args[MAX_OPT_ARGS]; 506 substring_t args[MAX_OPT_ARGS];
507 int token; 507 int token;
508 unsigned n;
508 if (!*p) 509 if (!*p)
509 continue; 510 continue;
510 511
@@ -516,7 +517,10 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
516 case Opt_bs: 517 case Opt_bs:
517 if (match_int(&args[0], &option)) 518 if (match_int(&args[0], &option))
518 return 0; 519 return 0;
519 uopt->blocksize = option; 520 n = option;
521 if (n != 512 && n != 1024 && n != 2048 && n != 4096)
522 return 0;
523 uopt->blocksize = n;
520 uopt->flags |= (1 << UDF_FLAG_BLOCKSIZE_SET); 524 uopt->flags |= (1 << UDF_FLAG_BLOCKSIZE_SET);
521 break; 525 break;
522 case Opt_unhide: 526 case Opt_unhide: