linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [RFC PATCH] btrfs: Remove 'objectid' member from struct btrfs_root
Date: Tue, 14 Aug 2018 21:22:10 +0800	[thread overview]
Message-ID: <2d574af1-c5eb-a65e-7006-86d5bb563026@gmx.com> (raw)
In-Reply-To: <20180813173715.GA24025@twin.jikos.cz>


[-- Attachment #1.1: Type: text/plain, Size: 1883 bytes --]



On 2018/8/14 上午1:37, David Sterba wrote:
> On Mon, Aug 06, 2018 at 02:17:54PM +0800, Qu Wenruo wrote:
>>> -	u64 objectid;
>>
>> Off topic crazy idea here.
>>
>> I think it is a little crazy, but it should save a lot of objectid
>> related modification:
>>
>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
>> index 118346aceea9..e6d70f2309a3 100644
>> --- a/fs/btrfs/ctree.h
>> +++ b/fs/btrfs/ctree.h
>> @@ -1166,7 +1166,10 @@ struct btrfs_root {
>>
>>         unsigned long state;
>>         struct btrfs_root_item root_item;
>> -       struct btrfs_key root_key;
>> +       union {
>> +               struct btrfs_key root_key;
>> +               u64 objectid;
>> +       };
>>         struct btrfs_fs_info *fs_info;
>>         struct extent_io_tree dirty_log_pages;
>>
>> @@ -1198,7 +1201,6 @@ struct btrfs_root {
>>         int last_log_commit;
>>         pid_t log_start_pid;
>>
>> -       u64 objectid;
>>         u64 last_trans;
>>
>>         u32 type;
>>
>> I'm not sure if this is a really crazy idea or a dirty hack to reduce
>> some modification.
> 
> Be wary of such tricks. This might make you feel good for a moment how
> good your C knowlege is, and also might save a few keystrokes. And a few
> years later this costs somebody a week of debugging a mysterious memory
> corrupption under circumstances not imagined right now.

Yep, that's why I'm calling this a "crazy idea" for the same reason.

Just wondering if there is any better way to do it without using a
trick, like anonymous structure inside btrfs_root?
(Purely to improve my C skill if possible)

Anyway, I'm completely OK with current patch.

Thanks,
Qu

> 
> Try to write understandable code. If there is a reason to use tricks,
> like the struct page has to do for performance reasons, then it must be
> documented and justified.
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2018-08-14 16:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1533531264.git.misono.tomohiro@jp.fujitsu.com>
2018-08-06  5:25 ` [RFC PATCH] btrfs: Remove 'objectid' member from struct btrfs_root Misono Tomohiro
2018-08-06  6:17   ` Qu Wenruo
2018-08-06  6:37     ` Su Yue
2018-08-06  6:41     ` Misono Tomohiro
2018-08-13 17:37     ` David Sterba
2018-08-14 13:22       ` Qu Wenruo [this message]
2018-08-13 17:38   ` David Sterba

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=2d574af1-c5eb-a65e-7006-86d5bb563026@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=misono.tomohiro@jp.fujitsu.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).