* [Ocfs2-devel] [PATCH v2] ocfs2: using the OCFS2_XATTR_ROOT_SIZE macro in ocfs2_reflink_xattr_header()
@ 2017-12-11 6:24 alex chen
2017-12-12 22:47 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: alex chen @ 2017-12-11 6:24 UTC (permalink / raw)
To: ocfs2-devel
Using the OCFS2_XATTR_ROOT_SIZE macro improves the readability of the code.
Signed-off-by: Alex Chen <alex.chen@huawei.com>
Reviewed-by: Jun Piao <piaojun@huawei.com>
---
fs/ocfs2/xattr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 5fdf269..ca3b61a 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -6415,7 +6415,7 @@ static int ocfs2_reflink_xattr_header(handle_t *handle,
* and then insert the extents one by one.
*/
if (xv->xr_list.l_tree_depth) {
- memcpy(new_xv, &def_xv, sizeof(def_xv));
+ memcpy(new_xv, &def_xv, OCFS2_XATTR_ROOT_SIZE);
vb->vb_xv = new_xv;
vb->vb_bh = value_bh;
ocfs2_init_xattr_value_extent_tree(&data_et,
-- 1.9.5.msysgit.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Ocfs2-devel] [PATCH v2] ocfs2: using the OCFS2_XATTR_ROOT_SIZE macro in ocfs2_reflink_xattr_header()
2017-12-11 6:24 [Ocfs2-devel] [PATCH v2] ocfs2: using the OCFS2_XATTR_ROOT_SIZE macro in ocfs2_reflink_xattr_header() alex chen
@ 2017-12-12 22:47 ` Andrew Morton
2017-12-13 7:49 ` alex chen
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2017-12-12 22:47 UTC (permalink / raw)
To: ocfs2-devel
On Mon, 11 Dec 2017 14:24:08 +0800 alex chen <alex.chen@huawei.com> wrote:
> Using the OCFS2_XATTR_ROOT_SIZE macro improves the readability of the code.
>
> Signed-off-by: Alex Chen <alex.chen@huawei.com>
> Reviewed-by: Jun Piao <piaojun@huawei.com>
> ---
> fs/ocfs2/xattr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 5fdf269..ca3b61a 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -6415,7 +6415,7 @@ static int ocfs2_reflink_xattr_header(handle_t *handle,
> * and then insert the extents one by one.
> */
> if (xv->xr_list.l_tree_depth) {
> - memcpy(new_xv, &def_xv, sizeof(def_xv));
> + memcpy(new_xv, &def_xv, OCFS2_XATTR_ROOT_SIZE);
> vb->vb_xv = new_xv;
> vb->vb_bh = value_bh;
> ocfs2_init_xattr_value_extent_tree(&data_et,
OK.
But what's wrong with
*new_xv = def_xv;
?
That gets typechecked and the compiler may be able to perform
some optimizations...
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Ocfs2-devel] [PATCH v2] ocfs2: using the OCFS2_XATTR_ROOT_SIZE macro in ocfs2_reflink_xattr_header()
2017-12-12 22:47 ` Andrew Morton
@ 2017-12-13 7:49 ` alex chen
0 siblings, 0 replies; 3+ messages in thread
From: alex chen @ 2017-12-13 7:49 UTC (permalink / raw)
To: ocfs2-devel
Hi Andrew,
Thanks for your suggestion.
On 2017/12/13 6:47, Andrew Morton wrote:
> On Mon, 11 Dec 2017 14:24:08 +0800 alex chen <alex.chen@huawei.com> wrote:
>
>> Using the OCFS2_XATTR_ROOT_SIZE macro improves the readability of the code.
>>
>> Signed-off-by: Alex Chen <alex.chen@huawei.com>
>> Reviewed-by: Jun Piao <piaojun@huawei.com>
>> ---
>> fs/ocfs2/xattr.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
>> index 5fdf269..ca3b61a 100644
>> --- a/fs/ocfs2/xattr.c
>> +++ b/fs/ocfs2/xattr.c
>> @@ -6415,7 +6415,7 @@ static int ocfs2_reflink_xattr_header(handle_t *handle,
>> * and then insert the extents one by one.
>> */
>> if (xv->xr_list.l_tree_depth) {
>> - memcpy(new_xv, &def_xv, sizeof(def_xv));
>> + memcpy(new_xv, &def_xv, OCFS2_XATTR_ROOT_SIZE);
>> vb->vb_xv = new_xv;
>> vb->vb_bh = value_bh;
>> ocfs2_init_xattr_value_extent_tree(&data_et,
>
> OK.
>
> But what's wrong with
>
> *new_xv = def_xv;
>
> ?
The type of new_xv is 'ocfs2_xattr_value_root' and the type of def_xv is 'ocfs2_xattr_def_value_root'.
The length of def_xv is larger than that of new_xv.
We initialize the new_xv to the empty default value root which have one extent record.
If we use method you describe above to copy, we may missed a copy of one extent record.
Thanks,
Alex
>
> That gets typechecked and the compiler may be able to perform
> some optimizations...
>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-13 7:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-11 6:24 [Ocfs2-devel] [PATCH v2] ocfs2: using the OCFS2_XATTR_ROOT_SIZE macro in ocfs2_reflink_xattr_header() alex chen
2017-12-12 22:47 ` Andrew Morton
2017-12-13 7:49 ` alex chen
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.