[PATCH] Btrfs: make sure there is always room for generation number
io_ctl_set_generation() assumes that the generation number shares the same page with inline CRCs. Let's make sure this is always true. Signed-off-by: Zhihui Zhang --- fs/btrfs/free-space-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index d5f80cb300be..9aa0fbf16515 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -300,9 +300,9 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode, if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FREE_INO_OBJECTID) check_crcs = 1; - /* Make sure we can fit our crcs into the first page */ + /* Make sure we can fit our crcs and generation # into the first page */ if (write && check_crcs && - (num_pages * sizeof(u32)) >= PAGE_SIZE) + (num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE) return -ENOSPC; memset(io_ctl, 0, sizeof(struct btrfs_io_ctl)); -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] Btrfs: make sure there is always room for generation number
code inspection. If I understand it correctly, we are off by 4 bytes because CRC is 32 bits and generation is 64 bits. But this bug might never hit in practice. thanks, -Zhihui On Wed, Jul 4, 2018 at 11:21 AM, David Sterba wrote: > On Mon, Jul 02, 2018 at 08:00:54PM -0400, Zhihui Zhang wrote: >> io_ctl_set_generation() assumes that the generation number shares >> the same page with inline CRCs. Let's make sure this is always true. >> >> Signed-off-by: Zhihui Zhang > > Reviewed-by: David Sterba -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: idea about internal fragmentation in Btrfs
Makes perfect sense. No wonder some btrfs folks used to work on reiserfs/4. I hope a solution can be or has been found. On Sat, Jun 19, 2010 at 4:51 PM, Andi Kleen wrote: > Zhihui Zhang writes: > >> I wish Btrfs well, so I would venture an idea for this specific case >> mentioned by Edward Shishkin today. >> >> Everyone knows that B-tree has internal and leaf nodes. Can we make >> the root as the leaf? In other words, if you >> create a 2K file, the B-tree will have only one node, which is both >> the root and the leaf. Of course, you need some flag to >> say this is a "degenerated" form of B-tree. Please cc me if you want >> my response. > > You need to copy linux-btrfs to reach btrfs developers. > Ccs added > > The problem with your idea is that on btrfs there's only > a single tree for the whole fs (or whole snapshot rather) > So it would only work for a single file because there's > only a single root. > > -Andi > -- > a...@linux.intel.com -- Speaking for myself only. > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html