Message ID | 20180130203221.29310-1-jlayton@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Ack. Should I expect this in a future pull request, or take it directly? There's no hurry about this, since none of the existing users of that function actually do anything but test the return value against zero, and nobody saves it into anything but a "bool" (which has magical casting properties and does not lose upper bits). Linus -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2018-01-30 at 12:53 -0800, Linus Torvalds wrote: > Ack. Should I expect this in a future pull request, or take it directly? > > There's no hurry about this, since none of the existing users of that > function actually do anything but test the return value against zero, > and nobody saves it into anything but a "bool" (which has magical > casting properties and does not lose upper bits). > > Linus Do you mind just taking it directly? I don't have anything else queued up for this cycle. Thanks,
On Wed, Jan 31, 2018 at 4:29 AM, Jeff Layton <jlayton@kernel.org> wrote: > > Do you mind just taking it directly? I don't have anything else queued > up for this cycle. Done. I wonder if "false for same, true for different" calling convention makes much sense, but it matches the old "0 for same" so obviously makes for a smaller diff. If it ever ends up confusing people, maybe the sense of that function should be reversed, and the name changed to something like "same_inode_version()" or something. But at least for now the situation seems ok to me, Linus -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 2018-01-31 at 08:46 -0800, Linus Torvalds wrote: > On Wed, Jan 31, 2018 at 4:29 AM, Jeff Layton <jlayton@kernel.org> wrote: > > > > Do you mind just taking it directly? I don't have anything else queued > > up for this cycle. > > Done. > Thanks...and also many thanks for spotting the original issue. I agree that this makes it much harder for the callers to get things wrong (and is probably much more efficient on some arches, as Ted pointed out). > I wonder if "false for same, true for different" calling convention > makes much sense, but it matches the old "0 for same" so obviously > makes for a smaller diff. > > If it ever ends up confusing people, maybe the sense of that function > should be reversed, and the name changed to something like > "same_inode_version()" or something. > > But at least for now the situation seems ok to me, > G. Baroncelli suggested changing the name too, so maybe we should just go ahead and do it. Let me think on what the best approach is and I may try to send another patch or PR before the end of the merge window. Cheers,
diff --git a/include/linux/iversion.h b/include/linux/iversion.h index 858463fca249..3d2fd06495ec 100644 --- a/include/linux/iversion.h +++ b/include/linux/iversion.h @@ -309,13 +309,13 @@ inode_query_iversion(struct inode *inode) * @inode: inode to check * @old: old value to check against its i_version * - * Compare the current raw i_version counter with a previous one. Returns 0 if - * they are the same or non-zero if they are different. + * Compare the current raw i_version counter with a previous one. Returns false + * if they are the same or true if they are different. */ -static inline s64 +static inline bool inode_cmp_iversion_raw(const struct inode *inode, u64 old) { - return (s64)inode_peek_iversion_raw(inode) - (s64)old; + return inode_peek_iversion_raw(inode) != old; } /** @@ -323,19 +323,15 @@ inode_cmp_iversion_raw(const struct inode *inode, u64 old) * @inode: inode to check * @old: old value to check against its i_version * - * Compare an i_version counter with a previous one. Returns 0 if they are - * the same, a positive value if the one in the inode appears newer than @old, - * and a negative value if @old appears to be newer than the one in the - * inode. + * Compare an i_version counter with a previous one. Returns false if they are + * the same, and true if they are different. * * Note that we don't need to set the QUERIED flag in this case, as the value * in the inode is not being recorded for later use. */ - -static inline s64 +static inline bool inode_cmp_iversion(const struct inode *inode, u64 old) { - return (s64)(inode_peek_iversion_raw(inode) & ~I_VERSION_QUERIED) - - (s64)(old << I_VERSION_QUERIED_SHIFT); + return inode_peek_iversion(inode) != old; } #endif