Skip to content

Commit a7963eb

Browse files
committed
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
2 parents b003d77 + 01d8885 commit a7963eb

14 files changed

Lines changed: 51 additions & 83 deletions

File tree

‎fs/ext2/acl.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
55
*/
66

7-
#include <linux/capability.h>
87
#include <linux/init.h>
98
#include <linux/sched.h>
109
#include <linux/slab.h>

‎fs/ext2/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
284284
int best_ndir = inodes_per_group;
285285
int best_group = -1;
286286

287-
get_random_bytes(&group, sizeof(group));
287+
group = prandom_u32();
288288
parent_group = (unsigned)group % ngroups;
289289
for (i = 0; i < ngroups; i++) {
290290
group = (parent_group + i) % ngroups;

‎fs/ext2/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static void init_once(void *foo)
192192
inode_init_once(&ei->vfs_inode);
193193
}
194194

195-
static int init_inodecache(void)
195+
static int __init init_inodecache(void)
196196
{
197197
ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
198198
sizeof(struct ext2_inode_info),

‎fs/ext2/xattr_security.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ ext2_xattr_security_set(struct dentry *dentry, const char *name,
4242
value, size, flags);
4343
}
4444

45-
int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
46-
void *fs_info)
45+
static int ext2_initxattrs(struct inode *inode, const struct xattr *xattr_array,
46+
void *fs_info)
4747
{
4848
const struct xattr *xattr;
4949
int err = 0;

‎fs/ext3/balloc.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,10 +1727,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
17271727
percpu_counter_sub(&sbi->s_freeblocks_counter, num);
17281728

17291729
BUFFER_TRACE(gdp_bh, "journal_dirty_metadata for group descriptor");
1730-
err = ext3_journal_dirty_metadata(handle, gdp_bh);
1731-
if (!fatal)
1732-
fatal = err;
1733-
1730+
fatal = ext3_journal_dirty_metadata(handle, gdp_bh);
17341731
if (fatal)
17351732
goto out;
17361733

‎fs/ext3/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static inline loff_t ext3_get_htree_eof(struct file *filp)
275275
* NOTE: offsets obtained *before* ext3_set_inode_flag(dir, EXT3_INODE_INDEX)
276276
* will be invalid once the directory was converted into a dx directory
277277
*/
278-
loff_t ext3_dir_llseek(struct file *file, loff_t offset, int whence)
278+
static loff_t ext3_dir_llseek(struct file *file, loff_t offset, int whence)
279279
{
280280
struct inode *inode = file->f_mapping->host;
281281
int dx_dir = is_dx_dir(inode);

‎fs/ext3/ialloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
215215
int best_ndir = inodes_per_group;
216216
int best_group = -1;
217217

218-
get_random_bytes(&group, sizeof(group));
218+
group = prandom_u32();
219219
parent_group = (unsigned)group % ngroups;
220220
for (i = 0; i < ngroups; i++) {
221221
group = (parent_group + i) % ngroups;

‎fs/ext3/inode.c‎

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,56 +1559,17 @@ static int buffer_unmapped(handle_t *handle, struct buffer_head *bh)
15591559
}
15601560

15611561
/*
1562-
* Note that we always start a transaction even if we're not journalling
1563-
* data. This is to preserve ordering: any hole instantiation within
1564-
* __block_write_full_page -> ext3_get_block() should be journalled
1565-
* along with the data so we don't crash and then get metadata which
1562+
* Note that whenever we need to map blocks we start a transaction even if
1563+
* we're not journalling data. This is to preserve ordering: any hole
1564+
* instantiation within __block_write_full_page -> ext3_get_block() should be
1565+
* journalled along with the data so we don't crash and then get metadata which
15661566
* refers to old data.
15671567
*
15681568
* In all journalling modes block_write_full_page() will start the I/O.
15691569
*
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-
*
16061570
* We don't honour synchronous mounts for writepage(). That would be
16071571
* disastrous. Any write() or metadata operation will sync the fs for
16081572
* 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.
16121573
*/
16131574
static int ext3_ordered_writepage(struct page *page,
16141575
struct writeback_control *wbc)
@@ -1673,12 +1634,9 @@ static int ext3_ordered_writepage(struct page *page,
16731634
* block_write_full_page() succeeded. Otherwise they are unmapped,
16741635
* and generally junk.
16751636
*/
1676-
if (ret == 0) {
1677-
err = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
1637+
if (ret == 0)
1638+
ret = walk_page_buffers(handle, page_bufs, 0, PAGE_CACHE_SIZE,
16781639
NULL, journal_dirty_data_fn);
1679-
if (!ret)
1680-
ret = err;
1681-
}
16821640
walk_page_buffers(handle, page_bufs, 0,
16831641
PAGE_CACHE_SIZE, NULL, bput_one);
16841642
err = ext3_journal_stop(handle);
@@ -1925,6 +1883,8 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
19251883
* and pretend the write failed... */
19261884
ext3_truncate_failed_direct_write(inode);
19271885
ret = PTR_ERR(handle);
1886+
if (inode->i_nlink)
1887+
ext3_orphan_del(NULL, inode);
19281888
goto out;
19291889
}
19301890
if (inode->i_nlink)
@@ -3212,21 +3172,20 @@ static int ext3_do_update_inode(handle_t *handle,
32123172
*
32133173
* We are called from a few places:
32143174
*
3215-
* - Within generic_file_write() for O_SYNC files.
3175+
* - Within generic_file_aio_write() -> generic_write_sync() for O_SYNC files.
32163176
* Here, there will be no transaction running. We wait for any running
32173177
* transaction to commit.
32183178
*
3219-
* - Within sys_sync(), kupdate and such.
3220-
* We wait on commit, if tol to.
3179+
* - Within flush work (for sys_sync(), kupdate and such).
3180+
* We wait on commit, if told to.
32213181
*
3222-
* - Within prune_icache() (PF_MEMALLOC == true)
3223-
* Here we simply return. We can't afford to block kswapd on the
3224-
* journal commit.
3182+
* - Within iput_final() -> write_inode_now()
3183+
* We wait on commit, if told to.
32253184
*
32263185
* In all cases it is actually safe for us to return without doing anything,
32273186
* 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
3229-
* knfsd.
3187+
* ext3_mark_inode_dirty(). This is a correctness thing for WB_SYNC_ALL
3188+
* writeback.
32303189
*
32313190
* Note that we are absolutely dependent upon all inode dirtiers doing the
32323191
* right thing: they *must* call mark_inode_dirty() after dirtying info in
@@ -3238,13 +3197,13 @@ static int ext3_do_update_inode(handle_t *handle,
32383197
* stuff();
32393198
* inode->i_size = expr;
32403199
*
3241-
* is in error because a kswapd-driven write_inode() could occur while
3242-
* `stuff()' is running, and the new i_size will be lost. Plus the inode
3243-
* will no longer be on the superblock's dirty inode list.
3200+
* is in error because write_inode() could occur while `stuff()' is running,
3201+
* and the new i_size will be lost. Plus the inode will no longer be on the
3202+
* superblock's dirty inode list.
32443203
*/
32453204
int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
32463205
{
3247-
if (current->flags & PF_MEMALLOC)
3206+
if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
32483207
return 0;
32493208

32503209
if (ext3_journal_current_handle()) {
@@ -3253,7 +3212,12 @@ int ext3_write_inode(struct inode *inode, struct writeback_control *wbc)
32533212
return -EIO;
32543213
}
32553214

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)
32573221
return 0;
32583222

32593223
return ext3_force_commit(inode->i_sb);

‎fs/ext3/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static void init_once(void *foo)
527527
inode_init_once(&ei->vfs_inode);
528528
}
529529

530-
static int init_inodecache(void)
530+
static int __init init_inodecache(void)
531531
{
532532
ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",
533533
sizeof(struct ext3_inode_info),

‎fs/ext3/xattr_security.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ ext3_xattr_security_set(struct dentry *dentry, const char *name,
4343
name, value, size, flags);
4444
}
4545

46-
int ext3_initxattrs(struct inode *inode, const struct xattr *xattr_array,
47-
void *fs_info)
46+
static int ext3_initxattrs(struct inode *inode,
47+
const struct xattr *xattr_array,
48+
void *fs_info)
4849
{
4950
const struct xattr *xattr;
5051
handle_t *handle = fs_info;

0 commit comments

Comments
 (0)