Skip to content

Commit 23aedc4

Browse files
committed
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "Only miscellaneous cleanups and bug fixes for ext4 this cycle" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: create ext4_kset dynamically ext4: create ext4_feat kobject dynamically ext4: release kobject/kset even when init/register fail ext4: fix incorrect indentation of if statement ext4: correct documentation for grpid mount option ext4: use 'sbi' instead of 'EXT4_SB(sb)' ext4: save error to disk in __ext4_grp_locked_error() jbd2: fix sphinx kernel-doc build warnings ext4: fix a race in the ext4 shutdown path mbcache: make sure c_entry_count is not decremented past zero ext4: no need flush workqueue before destroying it ext4: fixed alignment and minor code cleanup in ext4.h ext4: fix ENOSPC handling in DAX page fault handler dax: pass detailed error code from dax_iomap_fault() mbcache: revert "fs/mbcache.c: make count_objects() more robust" mbcache: initialize entry->e_referenced in mb_cache_entry_create() ext4: fix up remaining files with SPDX cleanups
2 parents 85b8bac + 5dc3971 commit 23aedc4

38 files changed

+407
-364
lines changed

Documentation/filesystems/ext4.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ data_err=ignore(*) Just print an error message if an error occurs
232232
data_err=abort Abort the journal if an error occurs in a file
233233
data buffer in ordered mode.
234234

235-
grpid Give objects the same group ID as their creator.
235+
grpid New objects have the group ID of their parent.
236236
bsdgroups
237237

238238
nogrpid (*) New objects have the group ID of their creator.

fs/dax.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ static bool dax_fault_is_synchronous(unsigned long flags,
10951095
}
10961096

10971097
static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp,
1098-
const struct iomap_ops *ops)
1098+
int *iomap_errp, const struct iomap_ops *ops)
10991099
{
11001100
struct vm_area_struct *vma = vmf->vma;
11011101
struct address_space *mapping = vma->vm_file->f_mapping;
@@ -1148,6 +1148,8 @@ static int dax_iomap_pte_fault(struct vm_fault *vmf, pfn_t *pfnp,
11481148
* that we never have to deal with more than a single extent here.
11491149
*/
11501150
error = ops->iomap_begin(inode, pos, PAGE_SIZE, flags, &iomap);
1151+
if (iomap_errp)
1152+
*iomap_errp = error;
11511153
if (error) {
11521154
vmf_ret = dax_fault_return(error);
11531155
goto unlock_entry;
@@ -1481,6 +1483,7 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp,
14811483
* @vmf: The description of the fault
14821484
* @pe_size: Size of the page to fault in
14831485
* @pfnp: PFN to insert for synchronous faults if fsync is required
1486+
* @iomap_errp: Storage for detailed error code in case of error
14841487
* @ops: Iomap ops passed from the file system
14851488
*
14861489
* When a page fault occurs, filesystems may call this helper in
@@ -1489,11 +1492,11 @@ static int dax_iomap_pmd_fault(struct vm_fault *vmf, pfn_t *pfnp,
14891492
* successfully.
14901493
*/
14911494
int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
1492-
pfn_t *pfnp, const struct iomap_ops *ops)
1495+
pfn_t *pfnp, int *iomap_errp, const struct iomap_ops *ops)
14931496
{
14941497
switch (pe_size) {
14951498
case PE_SIZE_PTE:
1496-
return dax_iomap_pte_fault(vmf, pfnp, ops);
1499+
return dax_iomap_pte_fault(vmf, pfnp, iomap_errp, ops);
14971500
case PE_SIZE_PMD:
14981501
return dax_iomap_pmd_fault(vmf, pfnp, ops);
14991502
default:

fs/ext2/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static int ext2_dax_fault(struct vm_fault *vmf)
100100
}
101101
down_read(&ei->dax_sem);
102102

103-
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, &ext2_iomap_ops);
103+
ret = dax_iomap_fault(vmf, PE_SIZE_PTE, NULL, NULL, &ext2_iomap_ops);
104104

105105
up_read(&ei->dax_sem);
106106
if (vmf->flags & FAULT_FLAG_WRITE)

fs/ext4/acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL-2.0 */
1+
// SPDX-License-Identifier: GPL-2.0
22
/*
33
File: fs/ext4/acl.h
44

fs/ext4/balloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
355355
blk = ext4_inode_table(sb, desc);
356356
offset = blk - group_first_block;
357357
next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
358-
EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group),
358+
EXT4_B2C(sbi, offset + sbi->s_itb_per_group),
359359
EXT4_B2C(sbi, offset));
360360
if (next_zero_bit <
361-
EXT4_B2C(sbi, offset + EXT4_SB(sb)->s_itb_per_group))
361+
EXT4_B2C(sbi, offset + sbi->s_itb_per_group))
362362
/* bad bitmap for inode tables */
363363
return blk;
364364
return 0;

fs/ext4/block_validity.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ int ext4_setup_system_zone(struct super_block *sb)
147147
int ret;
148148

149149
if (!test_opt(sb, BLOCK_VALIDITY)) {
150-
if (EXT4_SB(sb)->system_blks.rb_node)
150+
if (sbi->system_blks.rb_node)
151151
ext4_release_system_zone(sb);
152152
return 0;
153153
}
154-
if (EXT4_SB(sb)->system_blks.rb_node)
154+
if (sbi->system_blks.rb_node)
155155
return 0;
156156

157157
for (i=0; i < ngroups; i++) {
@@ -173,7 +173,7 @@ int ext4_setup_system_zone(struct super_block *sb)
173173
}
174174

175175
if (test_opt(sb, DEBUG))
176-
debug_print_tree(EXT4_SB(sb));
176+
debug_print_tree(sbi);
177177
return 0;
178178
}
179179

fs/ext4/ext4.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL-2.0 */
1+
// SPDX-License-Identifier: GPL-2.0
22
/*
33
* ext4.h
44
*
@@ -611,10 +611,10 @@ enum {
611611
/*
612612
* Flags used by ext4_free_blocks
613613
*/
614-
#define EXT4_FREE_BLOCKS_METADATA 0x0001
615-
#define EXT4_FREE_BLOCKS_FORGET 0x0002
616-
#define EXT4_FREE_BLOCKS_VALIDATED 0x0004
617-
#define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
614+
#define EXT4_FREE_BLOCKS_METADATA 0x0001
615+
#define EXT4_FREE_BLOCKS_FORGET 0x0002
616+
#define EXT4_FREE_BLOCKS_VALIDATED 0x0004
617+
#define EXT4_FREE_BLOCKS_NO_QUOT_UPDATE 0x0008
618618
#define EXT4_FREE_BLOCKS_NOFREE_FIRST_CLUSTER 0x0010
619619
#define EXT4_FREE_BLOCKS_NOFREE_LAST_CLUSTER 0x0020
620620

@@ -1986,10 +1986,10 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
19861986

19871987
/* Legal values for the dx_root hash_version field: */
19881988

1989-
#define DX_HASH_LEGACY 0
1990-
#define DX_HASH_HALF_MD4 1
1991-
#define DX_HASH_TEA 2
1992-
#define DX_HASH_LEGACY_UNSIGNED 3
1989+
#define DX_HASH_LEGACY 0
1990+
#define DX_HASH_HALF_MD4 1
1991+
#define DX_HASH_TEA 2
1992+
#define DX_HASH_LEGACY_UNSIGNED 3
19931993
#define DX_HASH_HALF_MD4_UNSIGNED 4
19941994
#define DX_HASH_TEA_UNSIGNED 5
19951995

@@ -2000,16 +2000,14 @@ static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc,
20002000
struct shash_desc shash;
20012001
char ctx[4];
20022002
} desc;
2003-
int err;
20042003

20052004
BUG_ON(crypto_shash_descsize(sbi->s_chksum_driver)!=sizeof(desc.ctx));
20062005

20072006
desc.shash.tfm = sbi->s_chksum_driver;
20082007
desc.shash.flags = 0;
20092008
*(u32 *)desc.ctx = crc;
20102009

2011-
err = crypto_shash_update(&desc.shash, address, length);
2012-
BUG_ON(err);
2010+
BUG_ON(crypto_shash_update(&desc.shash, address, length));
20132011

20142012
return *(u32 *)desc.ctx;
20152013
}

fs/ext4/ext4_extents.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* Copyright (c) 2003-2006, Cluster File Systems, Inc, [email protected]
34
* Written by Alex Tomas <[email protected]>
4-
*
5-
* This program is free software; you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License version 2 as
7-
* published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program; if not, write to the Free Software
16-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
175
*/
186

197
#ifndef _EXT4_EXTENTS

fs/ext4/ext4_jbd2.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
// SPDX-License-Identifier: GPL-2.0+
12
/*
23
* ext4_jbd2.h
34
*
45
* Written by Stephen C. Tweedie <[email protected]>, 1999
56
*
67
* Copyright 1998--1999 Red Hat corp --- All Rights Reserved
78
*
8-
* This file is part of the Linux kernel and is made available under
9-
* the terms of the GNU General Public License, version 2, or at your
10-
* option, any later version, incorporated herein by reference.
11-
*
129
* Ext4-specific journaling extensions.
1310
*/
1411

fs/ext4/extents.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* Copyright (c) 2003-2006, Cluster File Systems, Inc, [email protected]
34
* Written by Alex Tomas <[email protected]>
45
*
56
* Architecture independence:
67
* Copyright (c) 2005, Bull S.A.
78
* Written by Pierre Peiffer <[email protected]>
8-
*
9-
* This program is free software; you can redistribute it and/or modify
10-
* it under the terms of the GNU General Public License version 2 as
11-
* published by the Free Software Foundation.
12-
*
13-
* This program is distributed in the hope that it will be useful,
14-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-
* GNU General Public License for more details.
17-
*
18-
* You should have received a copy of the GNU General Public License
19-
* along with this program; if not, write to the Free Software
20-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-
219
*/
2210

2311
/*

fs/ext4/extents_status.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-License-Identifier: GPL-2.0 */
1+
// SPDX-License-Identifier: GPL-2.0
22
/*
33
* fs/ext4/extents_status.h
44
*

fs/ext4/file.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
280280
static int ext4_dax_huge_fault(struct vm_fault *vmf,
281281
enum page_entry_size pe_size)
282282
{
283-
int result;
283+
int result, error = 0;
284+
int retries = 0;
284285
handle_t *handle = NULL;
285286
struct inode *inode = file_inode(vmf->vma->vm_file);
286287
struct super_block *sb = inode->i_sb;
@@ -304,6 +305,7 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
304305
sb_start_pagefault(sb);
305306
file_update_time(vmf->vma->vm_file);
306307
down_read(&EXT4_I(inode)->i_mmap_sem);
308+
retry:
307309
handle = ext4_journal_start_sb(sb, EXT4_HT_WRITE_PAGE,
308310
EXT4_DATA_TRANS_BLOCKS(sb));
309311
if (IS_ERR(handle)) {
@@ -314,9 +316,13 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
314316
} else {
315317
down_read(&EXT4_I(inode)->i_mmap_sem);
316318
}
317-
result = dax_iomap_fault(vmf, pe_size, &pfn, &ext4_iomap_ops);
319+
result = dax_iomap_fault(vmf, pe_size, &pfn, &error, &ext4_iomap_ops);
318320
if (write) {
319321
ext4_journal_stop(handle);
322+
323+
if ((result & VM_FAULT_ERROR) && error == -ENOSPC &&
324+
ext4_should_retry_alloc(sb, &retries))
325+
goto retry;
320326
/* Handling synchronous page fault? */
321327
if (result & VM_FAULT_NEEDDSYNC)
322328
result = dax_finish_sync_fault(vmf, pe_size, pfn);

fs/ext4/fsmap.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0+
12
/*
23
* Copyright (C) 2017 Oracle. All Rights Reserved.
34
*
45
* Author: Darrick J. Wong <[email protected]>
5-
*
6-
* This program is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU General Public License
8-
* as published by the Free Software Foundation; either version 2
9-
* of the License, or (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it would be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write the Free Software Foundation,
18-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
196
*/
207
#include "ext4.h"
218
#include <linux/fsmap.h>

fs/ext4/fsmap.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0+
12
/*
23
* Copyright (C) 2017 Oracle. All Rights Reserved.
34
*
45
* Author: Darrick J. Wong <[email protected]>
5-
*
6-
* This program is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU General Public License
8-
* as published by the Free Software Foundation; either version 2
9-
* of the License, or (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it would be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write the Free Software Foundation,
18-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
196
*/
207
#ifndef __EXT4_FSMAP_H__
218
#define __EXT4_FSMAP_H__

fs/ext4/hash.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* linux/fs/ext4/hash.c
34
*
45
* Copyright (C) 2002 by Theodore Ts'o
5-
*
6-
* This file is released under the GPL v2.
7-
*
8-
* This file may be redistributed under the terms of the GNU Public
9-
* License.
106
*/
117

128
#include <linux/fs.h>

fs/ext4/ialloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
303303
/* Do this BEFORE marking the inode not in use or returning an error */
304304
ext4_clear_inode(inode);
305305

306-
es = EXT4_SB(sb)->s_es;
306+
es = sbi->s_es;
307307
if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
308308
ext4_error(sb, "reserved or nonexistent inode %lu", ino);
309309
goto error_return;
@@ -1157,7 +1157,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
11571157
ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
11581158
ext4_set_inode_state(inode, EXT4_STATE_NEW);
11591159

1160-
ei->i_extra_isize = EXT4_SB(sb)->s_want_extra_isize;
1160+
ei->i_extra_isize = sbi->s_want_extra_isize;
11611161
ei->i_inline_off = 0;
11621162
if (ext4_has_feature_inline_data(sb))
11631163
ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);

fs/ext4/inline.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
// SPDX-License-Identifier: LGPL-2.1
12
/*
23
* Copyright (c) 2012 Taobao.
34
* Written by Tao Ma <[email protected]>
4-
*
5-
* This program is free software; you can redistribute it and/or modify it
6-
* under the terms of version 2.1 of the GNU Lesser General Public License
7-
* as published by the Free Software Foundation.
8-
*
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
135
*/
146

157
#include <linux/iomap.h>

fs/ext4/inode.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3768,10 +3768,18 @@ static ssize_t ext4_direct_IO_write(struct kiocb *iocb, struct iov_iter *iter)
37683768
/* Credits for sb + inode write */
37693769
handle = ext4_journal_start(inode, EXT4_HT_INODE, 2);
37703770
if (IS_ERR(handle)) {
3771-
/* This is really bad luck. We've written the data
3772-
* but cannot extend i_size. Bail out and pretend
3773-
* the write failed... */
3774-
ret = PTR_ERR(handle);
3771+
/*
3772+
* We wrote the data but cannot extend
3773+
* i_size. Bail out. In async io case, we do
3774+
* not return error here because we have
3775+
* already submmitted the corresponding
3776+
* bio. Returning error here makes the caller
3777+
* think that this IO is done and failed
3778+
* resulting in race with bio's completion
3779+
* handler.
3780+
*/
3781+
if (!ret)
3782+
ret = PTR_ERR(handle);
37753783
if (inode->i_nlink)
37763784
ext4_orphan_del(NULL, inode);
37773785

0 commit comments

Comments
 (0)