Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

by-dnode methods let the caller save on dnode#->dnode_t lookup and im… #5534

Merged
merged 1 commit into from
Jan 13, 2017

Conversation

bzzz77
Copy link
Contributor

@bzzz77 bzzz77 commented Dec 28, 2016

…prove performance (especially multithread metadata ops)

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the ZFS on Linux code style requirements.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Change has been approved by a ZFS on Linux member.

@mention-bot
Copy link

@bzzz77, thanks for your PR! By analyzing the history of the files in this pull request, we identified @behlendorf, @ahrens and @nedbass to be potential reviewers.

@ahrens
Copy link
Member

ahrens commented Jan 2, 2017

IIRC, this is an updated version of #5464 (which doesn't seem to show the changes anymore)

Copy link
Member

@ahrens ahrens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good overall, just needs the few small changes I mentioned.

dmu_read(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
void *buf, uint32_t flags)
dmu_read_impl(dnode_t *dn, uint64_t offset, uint64_t size,
void *buf, uint32_t flags, void *tag)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the tag argument. This func can continue holding/releasing the dbufs using FTAG, because they are held/released by this function and not any others.

{
int err;
err = dmu_read_impl(dn, offset, size, buf, flags, FTAG);
return (err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] not a big deal, but if you want, you could simplify this to:

return (dmu_read_impl(...));

}
txh = dmu_tx_hold_dnode_impl(tx, os, dn, type, arg1, arg2);
if (txh != NULL && txh->txh_dnode != NULL)
dnode_rele(txh->txh_dnode, tx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the if statement here. dmu_tx_hold_dnode_impl() adds its own hold to the dnode. Therefore I think we should always release our hold, if we put one on. We can also use FTAG, since this func is the only one adding/removing its hold on the dnode. So this code should become:

if (object != DMU_NEW_OBJECT) {
    err = dnode_hold(os, object, FTAG, &dn);
    ...
...
if (dn != NULL) {
    dnode_rele(dn, FTAG);
}

}
if (!dmu_tx_is_syncing(tx))
(void) dmu_tx_hold_dnode_impl(tx, os,
dn, THT_NEWOBJECT, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Solaris / illumos style guide suggests braces { } around multi-line if bodies even if it's only one statement, for visual readability. But this isn't checked by the cstyle tool. I don't think it's a huge deal but that's why it's there now.

if (err != 0)
return (err);
err = zap_add_impl(zap, key, integer_size, num_integers, val, tx, FTAG);
if (zap != NULL) /* may be NULL if fzap_add() failed */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is no longer true. zap is passed by value, so there's no way for it to be changed. You'll need to either pass a pointer to it (&zap), or have zap_add_impl() do the zap_unlockdir() for us. Neither is that elegant, but I think the latter is less gross.

err = zap_lockdir_by_dnode(dn, tx, RW_WRITER, TRUE, TRUE, FTAG, &zap);
if (err != 0)
return (err);
err = zap_add_impl(zap, key, integer_size, num_integers, val, tx, FTAG);
if (zap != NULL) /* may be NULL if fzap_add() failed */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@bzzz77 bzzz77 force-pushed the bydnode-access branch 3 times, most recently from 1af2daa to 0900622 Compare January 9, 2017 12:23
@bzzz77
Copy link
Contributor Author

bzzz77 commented Jan 9, 2017

the patch has been updated according to Matt's review. thanks.

zn = zap_name_alloc(zap, key, MT_EXACT);
if (zn == NULL) {
zap_unlockdir(zap, FTAG);
return (SET_ERROR(ENOTSUP));
err = ENOTSUP;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The equivalent of the existing code would be err = SET_ERROR(ENOTSUP);

@ahrens
Copy link
Member

ahrens commented Jan 9, 2017

I've ported this to illumos and opened openzfs/openzfs#276

@ahrens
Copy link
Member

ahrens commented Jan 11, 2017

We should remove the unused os parameter to dmu_tx_hold_dnode_impl()

openzfs/openzfs#276 (comment)

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nit-picky things left to address and this LGTM.

@@ -823,16 +823,11 @@ dmu_free_range(objset_t *os, uint64_t object, uint64_t offset,
}

int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be defined as a static int return type.

{
return (dmu_read_impl(dn, offset, size, buf, flags));
}

void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be defined as a static void return type.

FALSE, FTAG, &numbufs, &dbp));

dmu_write_impl(dbp, numbufs, offset, size, buf, tx);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd remove the lines of extra white space around dmu_write_impl() so this is consistent with the formatting in dmu_read().

VERIFY0(dmu_buf_hold_array_by_dnode(dn, offset, size,
FALSE, FTAG, &numbufs, &dbp, DMU_READ_PREFETCH));

dmu_write_impl(dbp, numbufs, offset, size, buf, tx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same white space comment from dmu_write().

@@ -637,19 +669,16 @@ dmu_tx_mark_netfree(dmu_tx_t *tx)
}

void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static void

(void) dmu_tx_hold_free_impl(txh, off, len);
}

void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static void

EXPORT_SYMBOL(dmu_tx_hold_zap);
EXPORT_SYMBOL(dmu_tx_hold_zap_by_dnode);
EXPORT_SYMBOL(dmu_tx_hold_bonus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no matching EXPORT_SYMBOL for dmu_tx_hold_bonus_by_dnode() even though it was added to dmu.h. Let's add one here.

@@ -1289,22 +1316,16 @@ zap_remove(objset_t *os, uint64_t zapobj, const char *name, dmu_tx_t *tx)
}

int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static int

…prove performance (especially multithread metadata ops)
@bzzz77
Copy link
Contributor Author

bzzz77 commented Jan 13, 2017

the patch has been updated according to the reviews. thanks all.

Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM.

@behlendorf behlendorf merged commit 0eef1bd into openzfs:master Jan 13, 2017
wli5 pushed a commit to wli5/zfs that referenced this pull request Feb 28, 2017
Add *_by_dnode() routines for accessing objects given their
dnode_t *, this is more efficient than accessing the object by 
(objset_t *, uint64_t object).  This change converts some but
not all of the existing consumers.  As performance-sensitive
code paths are discovered they should be converted to use
these routines.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Closes openzfs#5534 
Issue openzfs#4802
wli5 pushed a commit to wli5/zfs that referenced this pull request Feb 28, 2017
Add *_by_dnode() routines for accessing objects given their
dnode_t *, this is more efficient than accessing the object by
(objset_t *, uint64_t object).  This change converts some but
not all of the existing consumers.  As performance-sensitive
code paths are discovered they should be converted to use
these routines.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Closes openzfs#5534
Issue openzfs#4802
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants