linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 027/237] btrfs: defrag: use btrfs_mod_outstanding_extents in cluster_pages_for_defrag
       [not found] <20191116154113.7417-1-sashal@kernel.org>
@ 2019-11-16 15:37 ` Sasha Levin
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent Sasha Levin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-11-16 15:37 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Su Yue, David Sterba, Sasha Levin, linux-btrfs

From: Su Yue <suy.fnst@cn.fujitsu.com>

[ Upstream commit 28c4a3e21ad030d7571ee9b1b246a5cbfd886627 ]

Since commit 8b62f87bad9c ("Btrfs: rework outstanding_extents"),
manual operations of outstanding_extent in btrfs_inode are replaced by
btrfs_mod_outstanding_extents().
The one in cluster_pages_for_defrag seems to be lost, so replace it
of btrfs_mod_outstanding_extents().

Fixes: 8b62f87bad9c ("Btrfs: rework outstanding_extents")
Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7592beb53fc4e..00ff4349b4579 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1337,7 +1337,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
 
 	if (i_done != page_cnt) {
 		spin_lock(&BTRFS_I(inode)->lock);
-		BTRFS_I(inode)->outstanding_extents++;
+		btrfs_mod_outstanding_extents(BTRFS_I(inode), 1);
 		spin_unlock(&BTRFS_I(inode)->lock);
 		btrfs_delalloc_release_space(inode, data_reserved,
 				start_index << PAGE_SHIFT,
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent
       [not found] <20191116154113.7417-1-sashal@kernel.org>
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 027/237] btrfs: defrag: use btrfs_mod_outstanding_extents in cluster_pages_for_defrag Sasha Levin
@ 2019-11-16 15:37 ` Sasha Levin
  2019-11-18 11:11   ` David Sterba
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 029/237] btrfs: handle error of get_old_root Sasha Levin
  2019-11-16 15:40 ` [PATCH AUTOSEL 4.19 195/237] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE Sasha Levin
  3 siblings, 1 reply; 6+ messages in thread
From: Sasha Levin @ 2019-11-16 15:37 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Liu Bo, David Sterba, Sasha Levin, linux-btrfs

From: Liu Bo <bo.liu@linux.alibaba.com>

[ Upstream commit de2c6615dcddf2af868c5cbd1db2e9e73b4beb58 ]

This fixes btrfs_get_extent to be consistent with our existing
declaration style.

Note: For the record, indentation styles that are accepted are both,
aligning under the opening ( and tab or double tab indentation on the
next line.  Preferrably not spliting the type or long expressions in the
argument lists.

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
[ add note ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/ctree.h | 4 ++--
 fs/btrfs/inode.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index cc2d268e2cd7a..3a5a09e8e20e2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3183,8 +3183,8 @@ struct inode *btrfs_iget_path(struct super_block *s, struct btrfs_key *location,
 struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
 			 struct btrfs_root *root, int *was_new);
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
-		struct page *page, size_t pg_offset,
-		u64 start, u64 end, int create);
+				    struct page *page, size_t pg_offset,
+				    u64 start, u64 end, int create);
 int btrfs_update_inode(struct btrfs_trans_handle *trans,
 			      struct btrfs_root *root,
 			      struct inode *inode);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f0f7bc5d2e4a0..62a7c6a88c3e8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6862,9 +6862,9 @@ static noinline int uncompress_inline(struct btrfs_path *path,
  * This also copies inline extents directly into the page.
  */
 struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
-		struct page *page,
-	    size_t pg_offset, u64 start, u64 len,
-		int create)
+				    struct page *page,
+				    size_t pg_offset, u64 start, u64 len,
+				    int create)
 {
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	int ret;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 4.19 029/237] btrfs: handle error of get_old_root
       [not found] <20191116154113.7417-1-sashal@kernel.org>
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 027/237] btrfs: defrag: use btrfs_mod_outstanding_extents in cluster_pages_for_defrag Sasha Levin
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent Sasha Levin
@ 2019-11-16 15:37 ` Sasha Levin
  2019-11-16 15:40 ` [PATCH AUTOSEL 4.19 195/237] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE Sasha Levin
  3 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-11-16 15:37 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Nikolay Borisov, Lu Fengqi, David Sterba, Sasha Levin, linux-btrfs

From: Nikolay Borisov <nborisov@suse.com>

[ Upstream commit 315bed43fea532650933e7bba316a7601d439edf ]

In btrfs_search_old_slot get_old_root is always used with the assumption
it cannot fail. However, this is not true in rare circumstance it can
fail and return null. This will lead to null point dereference when the
header is read. Fix this by checking the return value and properly
handling NULL by setting ret to -EIO and returning gracefully.

Coverity-id: 1087503
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/ctree.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 9fd383285f0ea..fc764f350f05a 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -3031,6 +3031,10 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key,
 
 again:
 	b = get_old_root(root, time_seq);
+	if (!b) {
+		ret = -EIO;
+		goto done;
+	}
 	level = btrfs_header_level(b);
 	p->locks[level] = BTRFS_READ_LOCK;
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 4.19 195/237] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE
       [not found] <20191116154113.7417-1-sashal@kernel.org>
                   ` (2 preceding siblings ...)
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 029/237] btrfs: handle error of get_old_root Sasha Levin
@ 2019-11-16 15:40 ` Sasha Levin
  3 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-11-16 15:40 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Arnd Bergmann, Nikolay Borisov, Changbin Du, David Sterba,
	Sasha Levin, linux-btrfs

From: Arnd Bergmann <arnd@arndb.de>

[ Upstream commit 7e17916b35797396f681a3270245fd29c1e4c250 ]

Note: this patch fixes a problem in a feature outside of btrfs ("kernel
hacking: add a config option to disable compiler auto-inlining") and is
applied ahead of time due to cross-subsystem dependencies.

On 32-bit ARM with gcc-8, I see a link error with the addition of the
CONFIG_NO_AUTO_INLINE option:

fs/btrfs/super.o: In function `btrfs_statfs':
super.c:(.text+0x67b8): undefined reference to `__aeabi_uldivmod'
super.c:(.text+0x67fc): undefined reference to `__aeabi_uldivmod'
super.c:(.text+0x6858): undefined reference to `__aeabi_uldivmod'
super.c:(.text+0x6920): undefined reference to `__aeabi_uldivmod'
super.c:(.text+0x693c): undefined reference to `__aeabi_uldivmod'
fs/btrfs/super.o:super.c:(.text+0x6958): more undefined references to `__aeabi_uldivmod' follow

So far this is the only file that shows the behavior, so I'd propose
to just work around it by marking the functions as 'static inline'
that normally get inlined here.

The reference to __aeabi_uldivmod comes from a div_u64() which has an
optimization for a constant division that uses a straight '/' operator
when the result should be known to the compiler. My interpretation is
that as we turn off inlining, gcc still expects the result to be constant
but fails to use that constant value.

Link: https://lkml.kernel.org/r/20181103153941.1881966-1-arnd@arndb.de
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Changbin Du <changbin.du@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[ add the note ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/btrfs/super.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8888337a95b64..ddbad8d509490 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1919,7 +1919,7 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 }
 
 /* Used to sort the devices by max_avail(descending sort) */
-static int btrfs_cmp_device_free_bytes(const void *dev_info1,
+static inline int btrfs_cmp_device_free_bytes(const void *dev_info1,
 				       const void *dev_info2)
 {
 	if (((struct btrfs_device_info *)dev_info1)->max_avail >
@@ -1948,8 +1948,8 @@ static inline void btrfs_descending_sort_devices(
  * The helper to calc the free space on the devices that can be used to store
  * file data.
  */
-static int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
-				       u64 *free_bytes)
+static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info,
+					      u64 *free_bytes)
 {
 	struct btrfs_device_info *devices_info;
 	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent
  2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent Sasha Levin
@ 2019-11-18 11:11   ` David Sterba
  2019-11-25 14:01     ` Sasha Levin
  0 siblings, 1 reply; 6+ messages in thread
From: David Sterba @ 2019-11-18 11:11 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel, stable, Liu Bo, David Sterba, linux-btrfs

On Sat, Nov 16, 2019 at 10:37:43AM -0500, Sasha Levin wrote:
> From: Liu Bo <bo.liu@linux.alibaba.com>
> 
> [ Upstream commit de2c6615dcddf2af868c5cbd1db2e9e73b4beb58 ]
> 
> This fixes btrfs_get_extent to be consistent with our existing
> declaration style.

The patch is pure white space fix with no effects. I don't see that it
would be needed for a followup patch. What was the reason to add it to
autosel/stable ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent
  2019-11-18 11:11   ` David Sterba
@ 2019-11-25 14:01     ` Sasha Levin
  0 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2019-11-25 14:01 UTC (permalink / raw)
  To: dsterba, linux-kernel, stable, Liu Bo, David Sterba, linux-btrfs

On Mon, Nov 18, 2019 at 12:11:43PM +0100, David Sterba wrote:
>On Sat, Nov 16, 2019 at 10:37:43AM -0500, Sasha Levin wrote:
>> From: Liu Bo <bo.liu@linux.alibaba.com>
>>
>> [ Upstream commit de2c6615dcddf2af868c5cbd1db2e9e73b4beb58 ]
>>
>> This fixes btrfs_get_extent to be consistent with our existing
>> declaration style.
>
>The patch is pure white space fix with no effects. I don't see that it
>would be needed for a followup patch. What was the reason to add it to
>autosel/stable ?

Oh I grabbed it as a dependency for a follow up patch which I ended up
dropping, and forgot this one in. I'll drop it as well, sorry for the
noise.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-25 14:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191116154113.7417-1-sashal@kernel.org>
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 027/237] btrfs: defrag: use btrfs_mod_outstanding_extents in cluster_pages_for_defrag Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 028/237] Btrfs: fix alignment in declaration and prototype of btrfs_get_extent Sasha Levin
2019-11-18 11:11   ` David Sterba
2019-11-25 14:01     ` Sasha Levin
2019-11-16 15:37 ` [PATCH AUTOSEL 4.19 029/237] btrfs: handle error of get_old_root Sasha Levin
2019-11-16 15:40 ` [PATCH AUTOSEL 4.19 195/237] btrfs: avoid link error with CONFIG_NO_AUTO_INLINE Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).