[<prev] [next>] [day] [month] [year] [list]
Message-ID: <PAXP193MB208932D21DE0E604AC51FBB8A7F19@PAXP193MB2089.EURP193.PROD.OUTLOOK.COM>
Date: Sat, 31 Dec 2022 14:41:21 +0000
From: "Siddhartha Menon" <siddharthamenon@...look.com>
To: <clm@...com>, <josef@...icpanda.com>, <dsterba@...e.com>,
<linux-btrfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] Check the return value of unpin_exten_cache. Cleanup style.
>From ef7af0146f74e6282ea5bb6ddd3573e12294d23a Mon Sep 17 00:00:00 2001
From: Siddhartha Menon <siddharthamenon@...look.com>
Date: Sat, 31 Dec 2022 14:22:25 +0000
Subject: [PATCH 0/2] Check the return value of unpin_exten_cache. Cleanup style.
These patches hopefully fix a bug and cleanup the style.
It seems that in inode.c:3335 the function `unpin_exten_cache` is called but it's
return value is not saved. Therefore the following if statement is checking an
old value of `ret`.
This is my first patch so I offer my sincerest apologies if I have done
something wrong. I am happy to receive feedback. Thank you.
Siddhartha Menon (2):
Check return value of unpin_exten_cache
Fix several style errors in fs/btrfs/inode.c
fs/btrfs/inode.c | 51 +++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 24 deletions(-)
--
2.39.0
>From b27046612d5ace53632617f671216ebb0ac200f6 Mon Sep 17 00:00:00 2001
From: Siddhartha Menon <siddharthamenon@...look.com>
Date: Sat, 31 Dec 2022 13:41:56 +0000
Subject: [PATCH 1/2] Check return value of unpin_exten_cache
Signed-off-by: Siddhartha Menon <siddharthamenon@...look.com>
---
fs/btrfs/inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8bcad9940154..cb95d47e4d02 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3331,7 +3331,7 @@ int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
ordered_extent->disk_num_bytes);
}
}
- unpin_extent_cache(&inode->extent_tree, ordered_extent->file_offset,
+ ret = unpin_extent_cache(&inode->extent_tree, ordered_extent->file_offset,
ordered_extent->num_bytes, trans->transid);
if (ret < 0) {
btrfs_abort_transaction(trans, ret);
--
2.39.0
>From ef7af0146f74e6282ea5bb6ddd3573e12294d23a Mon Sep 17 00:00:00 2001
From: Siddhartha Menon <siddharthamenon@...look.com>
Date: Sat, 31 Dec 2022 14:14:53 +0000
Subject: [PATCH 2/2] Fix several style errors in fs/btrfs/inode.c
Signed-off-by: Siddhartha Menon <siddharthamenon@...look.com>
---
fs/btrfs/inode.c | 49 +++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cb95d47e4d02..ee7ca0e69aa1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -366,6 +366,7 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
if (compress_type != BTRFS_COMPRESS_NONE) {
struct page *cpage;
int i = 0;
+
while (compressed_size > 0) {
cpage = compressed_pages[i];
cur_size = min_t(unsigned long, compressed_size,
@@ -1221,7 +1222,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
u64 blocksize = fs_info->sectorsize;
struct btrfs_key ins;
struct extent_map *em;
- unsigned clear_bits;
+ unsigned int clear_bits;
unsigned long page_ops;
bool extent_reserved = false;
int ret = 0;
@@ -1557,7 +1558,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
u64 num_chunks = DIV_ROUND_UP(end - start, SZ_512K);
int i;
bool should_compress;
- unsigned nofs_flag;
+ unsigned int nofs_flag;
const blk_opf_t write_flags = wbc_to_write_flags(wbc);
unlock_extent(&inode->io_tree, start, end, NULL);
@@ -1575,7 +1576,7 @@ static int cow_file_range_async(struct btrfs_inode *inode,
memalloc_nofs_restore(nofs_flag);
if (!ctx) {
- unsigned clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC |
+ unsigned int clear_bits = EXTENT_LOCKED | EXTENT_DELALLOC |
EXTENT_DELALLOC_NEW | EXTENT_DEFRAG |
EXTENT_DO_ACCOUNTING;
unsigned long page_ops = PAGE_UNLOCK | PAGE_START_WRITEBACK |
@@ -3846,7 +3847,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
ret = PTR_ERR(trans);
goto out;
}
- btrfs_debug(fs_info, "auto deleting %Lu",
+ btrfs_debug(fs_info, "auto deleting %llu",
found_key.objectid);
ret = btrfs_del_orphan_item(trans, root,
found_key.objectid);
@@ -3892,8 +3893,8 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
{
u32 nritems = btrfs_header_nritems(leaf);
struct btrfs_key found_key;
- static u64 xattr_access = 0;
- static u64 xattr_default = 0;
+ static u64 xattr_access;
+ static u64 xattr_default;
int scanned = 0;
if (!xattr_access) {
@@ -4920,7 +4921,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len,
bool only_release_metadata = false;
u32 blocksize = fs_info->sectorsize;
pgoff_t index = from >> PAGE_SHIFT;
- unsigned offset = from & (blocksize - 1);
+ unsigned int offset = from & (blocksize - 1);
struct page *page;
gfp_t mask = btrfs_alloc_write_mask(mapping);
size_t write_bytes = blocksize;
@@ -5358,7 +5359,7 @@ static void evict_inode_truncate_pages(struct inode *inode)
struct extent_state *cached_state = NULL;
u64 start;
u64 end;
- unsigned state_flags;
+ unsigned int state_flags;
node = rb_first(&io_tree->state);
state = rb_entry(node, struct extent_state, rb_node);
@@ -5842,7 +5843,7 @@ static struct inode *new_simple_dir(struct super_block *s,
inode->i_op = &simple_dir_inode_operations;
inode->i_opflags &= ~IOP_XATTR;
inode->i_fop = &simple_dir_operations;
- inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
+ inode->i_mode = 0755;
inode->i_mtime = current_time(inode);
inode->i_atime = inode->i_mtime;
inode->i_ctime = inode->i_mtime;
@@ -5983,7 +5984,7 @@ static int btrfs_opendir(struct inode *inode, struct file *file)
struct dir_entry {
u64 ino;
u64 offset;
- unsigned type;
+ unsigned int type;
int name_len;
};
@@ -6667,9 +6668,11 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
u64 local_index;
int err;
+
err = btrfs_del_root_ref(trans, key.objectid,
root->root_key.objectid, parent_ino,
&local_index, name);
+
if (err)
btrfs_abort_transaction(trans, err);
} else if (add_backref) {
@@ -8930,20 +8933,20 @@ void btrfs_destroy_inode(struct inode *vfs_inode)
while (1) {
ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
+
if (!ordered)
break;
- else {
- btrfs_err(root->fs_info,
- "found ordered extent %llu %llu on inode cleanup",
- ordered->file_offset, ordered->num_bytes);
- if (!freespace_inode)
- btrfs_lockdep_acquire(root->fs_info, btrfs_ordered_extent);
+ btrfs_err(root->fs_info,
+ "found ordered extent %llu %llu on inode cleanup",
+ ordered->file_offset, ordered->num_bytes);
- btrfs_remove_ordered_extent(inode, ordered);
- btrfs_put_ordered_extent(ordered);
- btrfs_put_ordered_extent(ordered);
- }
+ if (!freespace_inode)
+ btrfs_lockdep_acquire(root->fs_info, btrfs_ordered_extent);
+
+ btrfs_remove_ordered_extent(inode, ordered);
+ btrfs_put_ordered_extent(ordered);
+ btrfs_put_ordered_extent(ordered);
}
btrfs_qgroup_check_reserved_leak(inode);
inode_tree_del(inode);
@@ -9357,10 +9360,10 @@ static int btrfs_rename(struct user_namespace *mnt_userns,
if (ret) {
if (ret == -EEXIST) {
/* we shouldn't get
- * eexist without a new_inode */
- if (WARN_ON(!new_inode)) {
+ * eexist without a new_inode
+ */
+ if (WARN_ON(!new_inode))
goto out_fscrypt_names;
- }
} else {
/* maybe -EOVERFLOW */
goto out_fscrypt_names;
--
2.39.0
Powered by blists - more mailing lists