On 2020/7/3 上午7:46, David Sterba wrote: > On Thu, Jul 02, 2020 at 06:08:21PM +0200, David Sterba wrote: >> On Thu, Jul 02, 2020 at 07:56:57AM +0800, Qu Wenruo wrote: >>> On 2020/7/2 上午1:39, David Sterba wrote: >>>> On Wed, Jul 01, 2020 at 11:25:27AM +0800, Qu Wenruo wrote: >>>> Adding the anon_dev argument to btrfs_get_fs_root is wrong and I have >>>> never suggested that. What I meant is to put the actual id allocation >>>> to the callers where the subvolume is created, ie only 2 places. >>> >>> You mean to extract btrfs_init_fs_root() out of btrfs_get_fs_root()? >>> >>> That looks a little risky and I can't find any good solution to make it >>> more elegant than the current one. >> >> I spent more time reading through the get-fs-root functions and the main >> problem is that btrfs_get_fs_root is doing several things, and it makes >> a lot of code simple, I certainly want to keep it that way. >> >> The idea was to pre-insert the new root (similar to the root item >> insertion, btrfs_insert_root) and not letting btrfs_get_fs_root call to >> btrfs_init_fs_info where the anon_bdev allocation happens for all the >> other non-ioctl cases. >> >> Which could be done by factoring out btrfs_init_fs_root from >> btrfs_get_fs_root. This would allow to extend only btrfs_init_fs_root >> arguments with the anon_bdev, and keep btrfs_get_fs_root intact. >> So this is splitting the API from the end. >> >> What you originally proposed is a split from the begnning, ie. add a >> common implementation for existing and new and provide btrfs_get_fs_root >> and btrfs_get_new_fs_root that would hide the additional parameters. >> >> Both ways are IMO valid but I thought it would be easier to pass the >> anon bdev inside ioctl callbacks. The problem that makes my proposal >> less appealing is that btrfs_read_tree_root gets called earlier than >> I'd like so factoring everything after btrfs_init_fs_root would not be >> so straightforward. >> >> In conclusion, your proposal is better and I'm going to merge it. >> >>> Although I would definitely remove the "__" prefix as we shouldn't add >>> such prefix anymore. >> >> Yeah with the small naming fixups. > > It's in for-next-20200703. I've updated the changelogs to reflect what > we found during debugging the issue, the __ function renamed to > btrfs_get_root_ref and some function comments added. All patches > reordered and tagged for stable though the preallocation is not within > the size limit. > Thanks for the merge and dropping the unneeded check patch. All the modification looks good to me. Just a small nitpick for commit a561defc34aa ("btrfs: don't allocate anonymous block device for user invisible roots"), there is an unnecessary new line after "[CAUSE]". Thanks for your daily work of maintaining btrfs, Qu