-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
@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. |
IIRC, this is an updated version of #5464 (which doesn't seem to show the changes anymore) |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
1af2daa
to
0900622
Compare
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; |
There was a problem hiding this comment.
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);
I've ported this to illumos and opened openzfs/openzfs#276 |
0900622
to
1c400c9
Compare
We should remove the unused |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); | ||
|
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
1c400c9
to
ccde879
Compare
the patch has been updated according to the reviews. thanks all. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this LGTM.
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
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
…prove performance (especially multithread metadata ops)
Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: