From: Li Zefan <lizf@cn.fujitsu.com>
To: kreijack@libero.it
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 4/5] Btrfs: Add readonly snapshots support
Date: Fri, 10 Dec 2010 14:43:56 +0800 [thread overview]
Message-ID: <4D01CC2C.8030602@cn.fujitsu.com> (raw)
In-Reply-To: <201012092034.11019.kreijack@libero.it>
>> +#define BTRFS_ROOT_SNAP_RDONLY (1ULL << 0)
>> +
>> struct btrfs_root_item {
>> struct btrfs_inode_item inode;
>> __le64 generation;
>> @@ -1116,6 +1118,7 @@ struct btrfs_root {
>> int defrag_running;
>> char *name;
>> int in_sysfs;
>> + bool readonly;
>
> Does make sense to store the same information in two places ?
> If we have access to root->readonly, we have also access to "root-
>> root_item.flags". Because we need the latter, we can get rid of the former.
>
>
> We can replace a test like
>
> if(root->readonly)
>
> with
>
> if(root->root_item.flags & BTRFS_ROOT_SNAP_RDONLY)
>
> Or better we can create a two macros like:
>
> #define btrfs_root_readonly(x) ((x)->root_item.flags & BTRFS_ROOT_SNAP_RDONLY)
> #define btrfs_root_set_readonly(x, ro) \
> do{ (x)->root_item.flags = \
> ((x)->root_item.flags & ~BTRFS_ROOT_SNAP_RDONLY) | \
> (ro ? BTRFS_ROOT_SNAP_RDONLY : 0 ); \
> }while(0)
>
>
Makes sense.
(except that inline functions are preferable)
> Sorry for to be too late for this kind of suggestion. But I think that this
> optimization may help to avoid misalignment between the two variables (see my
> reply in the next patch).
> [...]
next prev parent reply other threads:[~2010-12-10 6:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-09 9:09 [PATCH v2 0/5] Btrfs: Readonly snapshots Li Zefan
2010-12-09 9:10 ` [PATCH v2 1/5] Btrfs: Make async snapshot ioctl more generic Li Zefan
2010-12-09 9:10 ` [PATCH v2 2/5] Btrfs: Refactor btrfs_ioctl_snap_create() Li Zefan
2010-12-09 9:10 ` [PATCH v2 3/5] Btrfs: Add helper __setup_root_post() Li Zefan
2010-12-09 9:11 ` [PATCH v2 4/5] Btrfs: Add readonly snapshots support Li Zefan
2010-12-09 19:34 ` Goffredo Baroncelli
2010-12-10 6:43 ` Li Zefan [this message]
2010-12-09 9:11 ` [PATCH v2 5/5] Btrfs: Add BTRFS_IOC_SUBVOL_GETFLAGS/SETFLAGS ioctl Li Zefan
2010-12-09 20:09 ` Goffredo Baroncelli
2010-12-10 7:12 ` Li Zefan
2010-12-10 7:49 ` Ian! D. Allen
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=4D01CC2C.8030602@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=kreijack@libero.it \
--cc=linux-btrfs@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.