Re: [PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers

2017-06-02 Thread Christoph Hellwig
On Fri, Jun 02, 2017 at 06:58:30PM +0200, David Sterba wrote: > Christoph pointed out that bio allocations backed by a bioset will never > fail. As we always use a bioset for all bio allocations, we can skip > the error handling. This patch adjusts our low-level helpers, the > cascaded changes

Re: crypto: Work around deallocated stack frame reference gcc bug on sparc.

2017-06-02 Thread David Miller
From: David Miller Date: Fri, 02 Jun 2017 14:39:06 -0400 (EDT) > From: "Darrick J. Wong" > Date: Fri, 2 Jun 2017 11:08:08 -0700 > >> ext4/jbd2's crc32c implementations will also need a fix like this for >> {ext4,jbd2}_chksum. Note that both of

Re: crypto: Work around deallocated stack frame reference gcc bug on sparc.

2017-06-02 Thread David Miller
From: "Darrick J. Wong" Date: Fri, 2 Jun 2017 11:08:08 -0700 > ext4/jbd2's crc32c implementations will also need a fix like this for > {ext4,jbd2}_chksum. Note that both of these modules call the crypto api > directly to avoid a static dependence on libcrc32c; this was

Re: [PATCH] Btrfs: skip commit transaction if we don't have enough pinned bytes

2017-06-02 Thread Omar Sandoval
On Fri, May 19, 2017 at 11:39:15AM -0600, Liu Bo wrote: > We commit transaction in order to reclaim space from pinned bytes because > it could process delayed refs, and in may_commit_transaction(), we check > first if pinned bytes are enough for the required space, we then check if > that plus

Re: crypto: Work around deallocated stack frame reference gcc bug on sparc.

2017-06-02 Thread Darrick J. Wong
[add ext4 list to cc] On Fri, Jun 02, 2017 at 11:28:54AM -0400, David Miller wrote: > > On sparc, if we have an alloca() like situation, as is the case with > SHASH_DESC_ON_STACK(), we can end up referencing deallocated stack > memory. The result can be that the value is clobbered if a trap >

Re: [PATCH v2 0/9] btrfs: check namelen before read name

2017-06-02 Thread David Sterba
On Fri, Jun 02, 2017 at 07:34:19PM +0200, David Sterba wrote: > On Thu, Jun 01, 2017 at 04:57:07PM +0800, Su Yue wrote: > > When reading out name from inode_ref, dir_item, it's possible that > > corrupted name_len leads to read beyond boundary. > > Since there are already patches for btrfs-progs,

Re: [PATCH v2 0/9] btrfs: check namelen before read name

2017-06-02 Thread David Sterba
On Thu, Jun 01, 2017 at 04:57:07PM +0800, Su Yue wrote: > When reading out name from inode_ref, dir_item, it's possible that > corrupted name_len leads to read beyond boundary. > Since there are already patches for btrfs-progs, this patchset is > for btrfs. > > Introduce 'btrfs_is_namelen_valid'

Re: [PATCH v2 6/9] btrfs: Check name before read in 'iterate_dir_item'

2017-06-02 Thread David Sterba
On Thu, Jun 01, 2017 at 12:58:12PM +0300, Nikolay Borisov wrote: > > > On 1.06.2017 11:57, Su Yue wrote: > > Since 'iterate_dir_item' checks namelen in its way, > > use 'btrfs_is_namelen_valid' not 'verify_dir_item'. > > > > Signed-off-by: Su Yue > > --- > >

[PATCH 7/8] btrfs: opencode trivial compressed_bio_alloc, simplify error handling

2017-06-02 Thread David Sterba
compressed_bio_alloc is now a trivial wrapper around btrfs_bio_alloc, no point keeping it. The error handling can be simplified, as we know btrfs_bio_alloc will never fail. Signed-off-by: David Sterba --- fs/btrfs/compression.c | 23 --- 1 file changed, 4

[PATCH 8/8] btrfs: pass bytes to btrfs_bio_alloc

2017-06-02 Thread David Sterba
Most callers of btrfs_bio_alloc convert from bytes to sectors. Hide that in the helper and simplify the logic in the callsers. Signed-off-by: David Sterba --- fs/btrfs/compression.c | 8 fs/btrfs/extent_io.c | 6 +++--- fs/btrfs/extent_io.h | 2 +- 3 files

[PATCH 5/8] btrfs: sink gfp parameter to btrfs_bio_clone

2017-06-02 Thread David Sterba
All callers pass GFP_NOFS. Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 4 ++-- fs/btrfs/extent_io.h | 2 +- fs/btrfs/inode.c | 2 +- fs/btrfs/volumes.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/extent_io.c

[PATCH 4/8] btrfs: btrfs_io_bio_alloc never fails, skip error handling

2017-06-02 Thread David Sterba
Update direct callers of btrfs_io_bio_alloc that do error handling, that we can now remove. Signed-off-by: David Sterba --- fs/btrfs/check-integrity.c | 5 - fs/btrfs/disk-io.c | 3 --- fs/btrfs/extent_io.c | 5 - fs/btrfs/raid56.c | 3 ---

[PATCH 6/8] btrfs: remove redundant parameters from btrfs_bio_alloc

2017-06-02 Thread David Sterba
All callers pass gfp_flags=GFP_NOFS and nr_vecs=BIO_MAX_PAGES. Signed-off-by: David Sterba --- fs/btrfs/compression.c | 2 +- fs/btrfs/extent_io.c | 9 +++-- fs/btrfs/extent_io.h | 4 +--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git

[PATCH 3/8] btrfs: btrfs_bio_clone never fails, skip error handling

2017-06-02 Thread David Sterba
Update direct callers of btrfs_bio_clone that do error handling, that we can now remove. Signed-off-by: David Sterba --- fs/btrfs/inode.c | 4 fs/btrfs/volumes.c | 1 - 2 files changed, 5 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index

[PATCH 2/8] btrfs: btrfs_bio_alloc never fails, skip error handling

2017-06-02 Thread David Sterba
Update direct callers of btrfs_bio_alloc that do error handling, that we can now remove. Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 78a787c36a35..17f80a18e787

[PATCH 1/8] btrfs: bioset allocations will never fail, adapt our helpers

2017-06-02 Thread David Sterba
Christoph pointed out that bio allocations backed by a bioset will never fail. As we always use a bioset for all bio allocations, we can skip the error handling. This patch adjusts our low-level helpers, the cascaded changes to all callers will come next. CC: Christoph Hellwig CC:

[PATCH 0/8] Bio allocation and error handling cleanups

2017-06-02 Thread David Sterba
The error handling can be simplified as we do bio allocations using a bioset as was pointed out by Christoph in https://lkml.kernel.org/r/20170516143737.ga24...@infradead.org David Sterba (8): btrfs: bioset allocations will never fail, adapt our helpers btrfs: btrfs_bio_alloc never fails,

crypto: Work around deallocated stack frame reference gcc bug on sparc.

2017-06-02 Thread David Miller
On sparc, if we have an alloca() like situation, as is the case with SHASH_DESC_ON_STACK(), we can end up referencing deallocated stack memory. The result can be that the value is clobbered if a trap or interrupt arrives at just the right instruction. It only occurs if the function ends

Re: [PATCH] Btrfs: fix delalloc accounting leak caused by u32 overflow

2017-06-02 Thread David Sterba
On Fri, Jun 02, 2017 at 01:20:01AM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > btrfs_calc_trans_metadata_size() does an unsigned 32-bit multiplication, > which can overflow if num_items >= 4 GB / (nodesize * BTRFS_MAX_LEVEL * 2). > For a nodesize of 16kB, this overflow

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Arnd Bergmann
On Fri, Jun 2, 2017 at 2:18 PM, Yan, Zheng wrote: > On Fri, Jun 2, 2017 at 7:33 PM, Arnd Bergmann wrote: >> On Fri, Jun 2, 2017 at 1:18 PM, Yan, Zheng wrote: >> What I meant is another related problem in ceph_mkdir() where the >> i_ctime

Re: [RFC PATCH v3.2 5/6] btrfs: qgroup: Introduce extent changeset for qgroup reserve functions

2017-06-02 Thread David Sterba
On Thu, Jun 01, 2017 at 09:01:26AM +0800, Qu Wenruo wrote: > > > At 05/31/2017 10:30 PM, David Sterba wrote: > > On Wed, May 31, 2017 at 08:31:35AM +0800, Qu Wenruo wrote: > Yes it's hard to find such deadlock especially when lockdep will not > detect it. > > And this makes

Re: [PATCH v2 6/6] btrfs-progs: test: Introduce functions to prepare and cleanup loop device

2017-06-02 Thread David Sterba
On Wed, May 31, 2017 at 01:56:10PM +0800, Qu Wenruo wrote: > +# prepare loop device using specified size and path > +# $1: path of the file > +# $2: size of the device, optional, default value is '2G' > +prepare_loop_dev() > +{ > + local path="$1" > + local size="$2" > + > + [[ "$path"

Re: [PATCH v2 0/6] Lowmem mode check check fix for mulit-device

2017-06-02 Thread David Sterba
On Wed, May 31, 2017 at 01:56:04PM +0800, Qu Wenruo wrote: > This patchset will fix a false alert in lowmem mode, which doesn't handle > RAID0/5/6/10 chunk well. (the 5th patch) > > Along the lowmem fix, also enhance and cleanup some chunk verification code, > as lowmem mode and original mode are

Re: [PATCH] generic: test Btrfs delalloc accounting overflow

2017-06-02 Thread David Sterba
On Fri, Jun 02, 2017 at 12:07:37PM +0300, Nikolay Borisov wrote: > > +# Make sure that we didn't leak any metadata space. > > +if [[ $FSTYP = btrfs ]]; then > > + uuid="$(findmnt -n -o UUID "$TEST_DIR")" > > if we are on btrfs and we don't have findmnt this test will likely fail. > Perhaps

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Yan, Zheng
On Fri, Jun 2, 2017 at 7:33 PM, Arnd Bergmann wrote: > On Fri, Jun 2, 2017 at 1:18 PM, Yan, Zheng wrote: >> On Fri, Jun 2, 2017 at 6:51 PM, Arnd Bergmann wrote: >>> On Fri, Jun 2, 2017 at 12:10 PM, Yan, Zheng wrote: On

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Arnd Bergmann
On Fri, Jun 2, 2017 at 1:18 PM, Yan, Zheng wrote: > On Fri, Jun 2, 2017 at 6:51 PM, Arnd Bergmann wrote: >> On Fri, Jun 2, 2017 at 12:10 PM, Yan, Zheng wrote: >>> On Fri, Jun 2, 2017 at 5:45 PM, Arnd Bergmann wrote: On

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Yan, Zheng
On Fri, Jun 2, 2017 at 6:51 PM, Arnd Bergmann wrote: > On Fri, Jun 2, 2017 at 12:10 PM, Yan, Zheng wrote: >> On Fri, Jun 2, 2017 at 5:45 PM, Arnd Bergmann wrote: >>> On Fri, Jun 2, 2017 at 4:09 AM, Yan, Zheng wrote: On

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Arnd Bergmann
On Fri, Jun 2, 2017 at 12:10 PM, Yan, Zheng wrote: > On Fri, Jun 2, 2017 at 5:45 PM, Arnd Bergmann wrote: >> On Fri, Jun 2, 2017 at 4:09 AM, Yan, Zheng wrote: >>> On Fri, Jun 2, 2017 at 8:57 AM, Deepa Dinamani >>>

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Yan, Zheng
On Fri, Jun 2, 2017 at 5:45 PM, Arnd Bergmann wrote: > On Fri, Jun 2, 2017 at 4:09 AM, Yan, Zheng wrote: >> On Fri, Jun 2, 2017 at 8:57 AM, Deepa Dinamani >> wrote: >>> On Thu, Jun 1, 2017 at 5:36 PM, John Stultz

[PATCH 1/2] btrfs-progs: Check slot + nr >= nritems overflow

2017-06-02 Thread Philipp Hahn
711a0b48683b71d61caffbd67a90ec8db5412675 is incomplete and missed the case in btrfs_del_ptr(), where multiple items are removed. > Running "btrfsck --repair /dev/sdd2" crashed as it can happen in > (corrupted) file systems, that slot > nritems. > ... > in that case the count of remaining items

[PATCH 2/2] btrfs-progs: Check nritems under-/overflow

2017-06-02 Thread Philipp Hahn
711a0b48683b71d61caffbd67a90ec8db5412675 is incomplete and missed some cases, where 'nritems' is outside its valid range, e.g. - insert_ptr(): inserting into an already full node - copy_for_split(): splitting more items than contained - btrfs_del_ptr(): deleting one item from an already empty node

[PATCH 0/2] More nritems range checking

2017-06-02 Thread Philipp Hahn
Hi, thank you for applying my last patch, but regarding my corrputed file system I found two other cases were btrfs crashes: - btrfs_del_items() was overlooked by me - deleting from an empty node Find attached two patches to improve that. Please check the second patch hunk 2, as I'm unsure if

Re: [PATCH 04/12] fs: ceph: CURRENT_TIME with ktime_get_real_ts()

2017-06-02 Thread Arnd Bergmann
On Fri, Jun 2, 2017 at 4:09 AM, Yan, Zheng wrote: > On Fri, Jun 2, 2017 at 8:57 AM, Deepa Dinamani wrote: >> On Thu, Jun 1, 2017 at 5:36 PM, John Stultz wrote: >>> On Thu, Jun 1, 2017 at 5:26 PM, Yan, Zheng

Re: [PATCH] generic: test Btrfs delalloc accounting overflow

2017-06-02 Thread Nikolay Borisov
On 2.06.2017 11:23, Omar Sandoval wrote: > From: Omar Sandoval > > This is a regression test for "[PATCH] Btrfs: fix delalloc accounting > leak caused by u32 overflow". It creates a bunch of delalloc extents and > merges them together to make sure the accounting is done right.

[PATCH] generic: test Btrfs delalloc accounting overflow

2017-06-02 Thread Omar Sandoval
From: Omar Sandoval This is a regression test for "[PATCH] Btrfs: fix delalloc accounting leak caused by u32 overflow". It creates a bunch of delalloc extents and merges them together to make sure the accounting is done right. Signed-off-by: Omar Sandoval ---

[PATCH] Btrfs: fix delalloc accounting leak caused by u32 overflow

2017-06-02 Thread Omar Sandoval
From: Omar Sandoval btrfs_calc_trans_metadata_size() does an unsigned 32-bit multiplication, which can overflow if num_items >= 4 GB / (nodesize * BTRFS_MAX_LEVEL * 2). For a nodesize of 16kB, this overflow happens at 16k items. Usually, num_items is a small constant passed to

[PATCH] btrfs: simplify code with bio_io_error

2017-06-02 Thread Guoqing Jiang
bio_io_error was introduced in the commit 4246a0b ("block: add a bi_error field to struct bio"), so use it to simplify code. Signed-off-by: Guoqing Jiang --- fs/btrfs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c

Re: [PATCH 10/12] apparmorfs: Replace CURRENT_TIME with current_time()

2017-06-02 Thread John Johansen
On 04/07/2017 05:57 PM, Deepa Dinamani wrote: > CURRENT_TIME macro is not y2038 safe on 32 bit systems. > > The patch replaces all the uses of CURRENT_TIME by > current_time(). > > This is also in preparation for the patch that transitions > vfs timestamps to use 64 bit time and hence make them