* [bug report] btrfs: zoned: enable relocation on a zoned filesystem
@ 2021-08-04 10:15 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2021-08-04 10:15 UTC (permalink / raw)
To: naohiro.aota; +Cc: linux-btrfs
Hello Naohiro Aota,
The patch 32430c614844: "btrfs: zoned: enable relocation on a zoned
filesystem" from Feb 4, 2021, leads to the following static checker
warning:
fs/btrfs/relocation.c:3777 __insert_orphan_inode()
warn: was expecting a 64 bit value instead of '(1 << 4)'
fs/btrfs/relocation.c
3767 static int __insert_orphan_inode(struct btrfs_trans_handle *trans,
3768 struct btrfs_root *root, u64 objectid)
3769 {
3770 struct btrfs_path *path;
3771 struct btrfs_inode_item *item;
3772 struct extent_buffer *leaf;
3773 u64 flags = BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC;
3774 int ret;
3775
3776 if (btrfs_is_zoned(trans->fs_info))
--> 3777 flags &= ~BTRFS_INODE_PREALLOC;
This code is supposed to clear out bit BTRFS_INODE_PREALLOC but it
actually clears out the top 32bits as well. The works in the current
code because even though "flags" is declared as a u64, only the lower
u32 bits are used.
For correctness and future proofing then probably we should declare
BTRFS_INODE_PREALLOC and friends as "1ULL << 4".
3778
3779 path = btrfs_alloc_path();
3780 if (!path)
3781 return -ENOMEM;
3782
3783 ret = btrfs_insert_empty_inode(trans, root, path, objectid);
3784 if (ret)
3785 goto out;
3786
3787 leaf = path->nodes[0];
3788 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_inode_item);
3789 memzero_extent_buffer(leaf, (unsigned long)item, sizeof(*item));
3790 btrfs_set_inode_generation(leaf, item, 1);
3791 btrfs_set_inode_size(leaf, item, 0);
3792 btrfs_set_inode_mode(leaf, item, S_IFREG | 0600);
3793 btrfs_set_inode_flags(leaf, item, flags);
^^^^^
The btrfs_set_inode_flags() function takes a u64.
3794 btrfs_mark_buffer_dirty(leaf);
3795 out:
3796 btrfs_free_path(path);
3797 return ret;
3798 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-04 10:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 10:15 [bug report] btrfs: zoned: enable relocation on a zoned filesystem Dan Carpenter
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).