[DragonFlyBSD - Submit #2772] (Closed) [PATCH] sys/vfs/hammer: make use of hammer_xlate_to_zone2()

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Sat Jan 17 12:53:39 PST 2015

Issue #2772 has been updated by dillon.

Status changed from New to Closed

Applied to master in f4fe61c211f76405279f2734eaff5e7285174523.

The only real modification I made was to the hammer_xlate_to_zone2() macro.  The use of 'offset' in the macro body had to be enclosed in parenthesis in order to ensure that no arithmatic reordering occurs if something complex is passed into the macro as its argument (e.g. in some future use case).

Generally speaking I support inline replacements which make the code more clear.  Yes, the reason I don't use them quite as much is precisely because over-use can often hide complexities that need to be understood when reading the higher level code.  But in this case it does make things more clear so it is ok.


Submit #2772: [PATCH] sys/vfs/hammer: make use of hammer_xlate_to_zone2()

* Author: tkusumi
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: VFS subsystem
* Target version: 
This patch makes use of the new macro hammer_xlate_to_zone2() I've added in the previous patch in http://bugs.dragonflybsd.org/issues/2771

I see hammer source does not prefer to use bunch of macros over macros, but rather use raw and/or bitwise operation probably to keep simplicity of the code as well as its design. However a piece of code like (a) makes it difficult to understand what it's trying to do. Using this macro makes it look like (b) which to me makes better sense.

(b) base_off = hammer_xlate_to_zone2(zone_offset & ~HAMMER_LARGEBLOCK_MASK64);

Since I've already sent a patch with such a macro to translate zones and the fact that zoneX-to-zone2 translation does have a meaning, I'd like to use that in other functions of blockmap code. There is no logical change here as following unittest shows.

\# cat ./unittest.c
\#include <stdio.h>
\#include <assert.h>
\#include <vfs/hammer/hammer_disk.h>

/* new macro */
\#define hammer_xlate_to_zone2(offset) \

/* mimic blockmap translation */
static void assert_blockmap_translation(hammer_off_t next_offset) {
	hammer_off_t base_off1, base_off2;

	base_off1 = (next_offset &
	base_off2 = hammer_xlate_to_zone2(next_offset &

	printf("next = 0x%08lX\n", next_offset);
	printf("off1 = 0x%08lX\n", base_off1);
	printf("off2 = 0x%08lX\n", base_off2);
	assert(base_off1 == base_off2);

int main(void) {
	return 0;
\# gcc -Wall -g ./unittest.c -o unittest
\# ./unittest
next = 0xA011223344556677
off1 = 0x2011223344000000
off2 = 0x2011223344000000
off1 = 0x2FFFFFFFFF800000
off2 = 0x2FFFFFFFFF800000

This patch goes on top of following two patches I've submitted. Sorry that the patch series # is disconnected from the previous two.
[PATCH 1/2] sys/vfs/hammer: make variable names up-to-date with code
[PATCH 2/2] sys/vfs/hammer: make hammer_blockmap_lookup() lightweight

0001-sys-vfs-hammer-make-use-of-hammer_xlate_to_zone2.patch (5.85 KB)

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

More information about the Submit mailing list