From: Dan Carpenter <dan.carpenter@oracle.com>
To: naohiro.aota@wdc.com
Cc: linux-btrfs@vger.kernel.org
Subject: [bug report] btrfs: zoned: enable relocation on a zoned filesystem
Date: Wed, 4 Aug 2021 13:15:41 +0300 [thread overview]
Message-ID: <20210804101541.GA12165@kili> (raw)
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
reply other threads:[~2021-08-04 10:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210804101541.GA12165@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).