R: Re: [PATCH v2 5/5] Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctl
Quoted 20 lines
----Messaggio originale----
Da: [email protected]
Data: 10/12/2010 8.12
A: <[email protected]>
Cc: <[email protected]>
Ogg: Re: [PATCH v2 5/5] Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctlQuoted 10 lines · Goffredo Baroncelli
Hi Li,
Quoted 7 lines · Li Zefan
This allows us to set a snapshot or a subvolume readonly or writable on the fly.
Usage:
Set
BTRFS_SUBVOL_RDONLYofbtrfs_ioctl_vol_arg_v2->flags, and then callioctl(BTRFS_IOCTL_SUBVOL_SETFLAGS);
[...]
Quoted 6 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ /* nothing to do */ + if (!!(flags & BTRFS_SUBVOL_RDONLY) == root->readonly) + goto out_unlock;This is only an aesthetic comment: I prefer a simpler style like
Quoted 6 lines
Quoted 3 lines
if ((flags & BTRFS_SUBVOL_RDONLY) && root->readonly) goto out_unlock;They are not equivalent. The former checks if the flags and the root both have readonly bit set or cleared.
Right, my fault
Quoted 13 lines
Quoted 13 lines
But I know that every body has its style :-)
Review
Quoted 9 lines
(quoted diff) +9
-0+ + root_flags = btrfs_root_flags(&root->root_item); + if (flags & BTRFS_SUBVOL_RDONLY) + btrfs_set_root_flags(&root->root_item, + root_flags | BTRFS_ROOT_SNAP_RDONLY); + else + btrfs_set_root_flags(&root->root_item, + root_flags & ~BTRFS_ROOT_SNAP_RDONLY); + root->readonly = !root->readonly;I double checked this line. But if I read the code correctly I think that
the
Quoted 7 lines
Quoted 3 lines
line above is wrong: the field "
root->readonly" is flipped regardless the value of the flags passed by the user.Yep, that's because if we don't need to flip it, we've already exited early.
Note, there's only one flag.
Yes, it is true. However I strongly suggest to avoid that. If someone adds another flag this may miss...
Obviously if we get rid of the root->readonly we solve at the root the problem :)
Quoted 2 lines
Quoted 2 lines
Moreover I have another question: why internally the flags is
BTRFS_ROOT_SNAP_RDONLY, instead in user space the flag is
BTRFS_SUBVOL_RDONLY
Quoted 9 lines
Quoted 2 lines
?
That's my carelessness..
Quoted 4 lines
I suggest to
- renameBTRFS_SUBVOL_RDONLYinBTRFS_SUBVOL_CREATE_SNAP_RDONLY(likeBTRFS_SUBVOL_CREATE_SNAP_ASYNC)
- renameBTRFS_ROOT_SNAP_RDONLYinBTRFS_ROOT_FLAGS_RDONLYand use both
in
Quoted 1 line
Quoted 1 line
userspace and in kernel space this flag. I suggested to remove SNAP
because
Quoted 9 lines
Quoted 2 lines
the flag make sense also for a "standard" subvolume.
I'd prefer not to mix flags for
root_itemflags and vol ioctl flags.And
CREATE_RDONLYandCREATE_ASYNCcan also be valid for subvolumes too. Support for async subvolume creation is already there, just lack of an user interface. So I've changed_CREATE_SNAP_ASYNCto_CREATE_ASYNCin the patch I sent just now.
I fully gree
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html