sys/vfs/hammer: Add HAMMER_BUFSIZE_DOALIGN() and variants
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 6 Nov 2016 06:35:28 +0000 (15:35 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 6 Nov 2016 09:58:20 +0000 (18:58 +0900)
The only reason it's "DOALIGN" instead of just "ALIGN" is
because that's how macros have been named in HAMMER1/2.
"ALIGN" macros represent alignment size.

sbin/newfs_hammer/newfs_hammer.c
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_ondisk.c

index 1f0f6ae..b8c4e57 100644 (file)
@@ -216,7 +216,7 @@ main(int ac, char **av)
                HeaderJunkSize = HAMMER_VOL_JUNK_SIZE;
        else if (HeaderJunkSize < (int64_t)sizeof(struct hammer_volume_ondisk))
                HeaderJunkSize = sizeof(struct hammer_volume_ondisk);
-       HeaderJunkSize = (HeaderJunkSize + HAMMER_BUFMASK) & ~HAMMER_BUFMASK;
+       HeaderJunkSize = HAMMER_BUFSIZE_DOALIGN(HeaderJunkSize);
 
        /*
         * Calculate defaults for the boot area and memory log sizes,
index 2caa904..fcde716 100644 (file)
 
 #define HAMMER_OFF_BAD         ((hammer_off_t)-1)
 
+#define HAMMER_BUFSIZE_DOALIGN(offset)                         \
+       (((offset) + HAMMER_BUFMASK) & ~HAMMER_BUFMASK)
+#define HAMMER_BUFSIZE64_DOALIGN(offset)                       \
+       (((offset) + HAMMER_BUFMASK64) & ~HAMMER_BUFMASK64)
+
+#define HAMMER_XBUFSIZE_DOALIGN(offset)                                \
+       (((offset) + HAMMER_XBUFMASK) & ~HAMMER_XBUFMASK)
+#define HAMMER_XBUFSIZE64_DOALIGN(offset)                      \
+       (((offset) + HAMMER_XBUFMASK64) & ~HAMMER_XBUFMASK64)
+
 /*
  * The current limit of volumes that can make up a HAMMER FS
  */
index 697b2a0..253bec5 100644 (file)
@@ -1151,7 +1151,7 @@ void *
 hammer_bread_ext(hammer_mount_t hmp, hammer_off_t buf_offset, int bytes,
                 int *errorp, hammer_buffer_t *bufferp)
 {
-       bytes = (bytes + HAMMER_BUFMASK) & ~HAMMER_BUFMASK;
+       bytes = HAMMER_BUFSIZE_DOALIGN(bytes);
        return(_hammer_bread(hmp, buf_offset, bytes, 0, errorp, bufferp));
 }
 
@@ -1176,7 +1176,7 @@ void *
 hammer_bnew_ext(hammer_mount_t hmp, hammer_off_t buf_offset, int bytes,
                int *errorp, hammer_buffer_t *bufferp)
 {
-       bytes = (bytes + HAMMER_BUFMASK) & ~HAMMER_BUFMASK;
+       bytes = HAMMER_BUFSIZE_DOALIGN(bytes);
        return(_hammer_bread(hmp, buf_offset, bytes, 1, errorp, bufferp));
 }