From: Joel Becker <Joel.Becker@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 01/14] ocfs2: Introduce ocfs2_xa_loc
Date: Thu, 27 Aug 2009 02:28:49 -0700 [thread overview]
Message-ID: <20090827092848.GB29402@mail.oracle.com> (raw)
In-Reply-To: <4A963A43.70009@oracle.com>
On Thu, Aug 27, 2009 at 03:48:19PM +0800, Tao Ma wrote:
> Joel Becker wrote:
> >+ u64 value_size = le64_to_cpu(entry->xe_value_size);
> >+
> >+ namevalue_size = OCFS2_XATTR_SIZE(entry->xe_name_len);
> >+ if (value_size > OCFS2_XATTR_INLINE_SIZE)
> >+ namevalue_size += OCFS2_XATTR_ROOT_SIZE;
> >+ else
> >+ namevalue_size += OCFS2_XATTR_SIZE(value_size);
> A minor issue. I see a similar part in the function in
> ocfs2_xa_block_wipe_namevalue, so can we create a inline function
> for it? maybe ocfs2_xe_name_value_size?
See patch 5 :-)
> >@@ -1376,7 +1586,14 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode,
> > {
> > size_t name_len = strlen(xi->name);
> > int i;
> >+ struct ocfs2_xa_loc loc;
> >+ if (xs->xattr_bh == xs->inode_bh)
> >+ ocfs2_init_dinode_xa_loc(&loc, inode, xs->inode_bh,
> >+ xs->not_found ? NULL : xs->here);
> >+ else
> >+ ocfs2_init_xattr_block_xa_loc(&loc, xs->xattr_bh,
> >+ xs->not_found ? NULL : xs->here);
> > if (xi->value && xs->not_found) {
> > /* Insert the new xattr entry. */
> > le16_add_cpu(&xs->header->xh_count, 1);
> >@@ -1415,9 +1632,9 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode,
> > xi->value_len);
> > return;
> > }
> >+
> > /* Remove the old name+value. */
> >- memmove(first_val + size, first_val, val - first_val);
> >- memset(first_val, 0, size);
> >+ ocfs2_xa_wipe_namevalue(&loc);
> > xs->here->xe_name_hash = 0;
> > xs->here->xe_name_offset = 0;
> > ocfs2_xattr_set_local(xs->here, 1);
> >@@ -1425,23 +1642,16 @@ static void ocfs2_xattr_set_entry_local(struct inode *inode,
> > min_offs += size;
> >- /* Adjust all value offsets. */
> >- last = xs->header->xh_entries;
> >- for (i = 0 ; i < le16_to_cpu(xs->header->xh_count); i++) {
> >- size_t o = le16_to_cpu(last->xe_name_offset);
> >-
> >- if (o < offs)
> >- last->xe_name_offset = cpu_to_le16(o + size);
> >- last += 1;
> >- }
> >-
> > if (!xi->value) {
> > /* Remove the old entry. */
> >- last -= 1;
> >+ i = le16_to_cpu(xs->header->xh_count);
> >+ i--;
> any reason why not "i = le16_to_cpu(xs->header->xh_count) - 1"?
No good one. I moved these couple lines around a bit, so I
probably was just adjusting.
> >+ last = &xs->header->xh_entries[i - 1];
> here is a bug. last should be "&xs->header->xh_entries[i]". In the
> old implementation, the above "for" loop ends with last =
> xh_entries[xh_count].
My brain wants to protest, but every time I walk the logic you
come out right. Maybe this used to be above the i-- or something.
Good catch.
Joel
--
"Always give your best, never get discouraged, never be petty; always
remember, others may hate you. Those who hate you don't win unless
you hate them. And then you destroy yourself."
- Richard M. Nixon
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
next prev parent reply other threads:[~2009-08-27 9:28 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 19:54 [Ocfs2-devel] [PATCH 0/14] ocfs2: Unify the setting of extended attributes Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 01/14] ocfs2: Introduce ocfs2_xa_loc Joel Becker
2009-08-27 7:48 ` Tao Ma
2009-08-27 9:28 ` Joel Becker [this message]
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 02/14] ocfs2: Remove xattrs via ocfs2_xa_loc Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 03/14] ocfs2: Prefix the member fields of struct ocfs2_xattr_info Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 04/14] ocfs2: Add a name_len field to ocfs2_xattr_info Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 05/14] ocfs2: Wrap calculation of name+value pair size Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 06/14] ocfs2: Set the xattr name+value pair in one place Joel Becker
2009-09-02 9:34 ` Tiger Yang
2009-09-02 10:30 ` Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 07/14] ocfs2: Handle value tree roots in ocfs2_xa_set_inline_value() Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 08/14] ocfs2: Provide ocfs2_xa_fill_value_buf() for external value processing Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 09/14] ocfs2: Teach ocfs2_xa_loc how to do its own journal work Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 10/14] ocfs2: Allocation in ocfs2_xa_prepare_entry() values in ocfs2_xa_store_value() Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 11/14] ocfs2: Gell into ocfs2_xa_set() Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 12/14] ocfs2: Let ocfs2_xa_prepare_entry() do space checks Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 13/14] ocfs2: Set xattr block entries with ocfs2_xa_set() Joel Becker
2009-08-19 19:54 ` [Ocfs2-devel] [PATCH 14/14] ocfs2: Set inline xattr " Joel Becker
2009-08-20 2:03 ` [Ocfs2-devel] [PATCH 0/14] ocfs2: Unify the setting of extended attributes Tao Ma
-- strict thread matches above, loose matches on Subject: below --
2009-08-28 8:35 Joel Becker
2009-08-28 8:35 ` [Ocfs2-devel] [PATCH 01/14] ocfs2: Introduce ocfs2_xa_loc Joel Becker
2009-09-01 5:32 ` Tao Ma
2009-09-01 8:26 ` Joel Becker
2009-09-01 8:45 ` Joel Becker
2009-09-01 8:49 ` Tao Ma
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=20090827092848.GB29402@mail.oracle.com \
--to=joel.becker@oracle.com \
--cc=ocfs2-devel@oss.oracle.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 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.