HAMMER VFS - Feature add to HAMMER_IOC_MIRROR_READ
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 11 Feb 2010 05:11:37 +0000 (21:11 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 11 Feb 2010 05:11:37 +0000 (21:11 -0800)
* Adds the HAMMER_IOC_MIRROR_NODATA flag to HAMMER_IOC_MIRROR_READ.
  This flag requests that HAMMER not return the data associated with
  b-tree records and may be used to quickly scan the b-tree.

sys/vfs/hammer/hammer_ioctl.h
sys/vfs/hammer/hammer_mirror.c

index ace6fef..f0778ed 100644 (file)
@@ -284,6 +284,8 @@ struct hammer_ioc_mirror_rw {
        uuid_t                  shared_uuid;    /* validator for safety */
 };
 
+#define HAMMER_IOC_MIRROR_NODATA       0x0001  /* do not include bulk data */
+
 /*
  * NOTE: crc is for the data block starting at rec_size, not including the
  * data[] array.
@@ -374,6 +376,8 @@ typedef union hammer_ioc_mrecord_any *hammer_ioc_mrecord_any_t;
 
 #define HAMMER_MREC_TYPE_REC_BADCRC    (HAMMER_MREC_TYPE_REC | \
                                         HAMMER_MRECF_CRC_ERROR)
+#define HAMMER_MREC_TYPE_REC_NODATA    (HAMMER_MREC_TYPE_REC | \
+                                        HAMMER_MRECF_NODATA)
 
 #define HAMMER_MRECF_TYPE_LOMASK       0x000000FF
 #define HAMMER_MRECF_TYPE_MASK         0x800000FF
@@ -381,6 +385,7 @@ typedef union hammer_ioc_mrecord_any *hammer_ioc_mrecord_any_t;
 
 #define HAMMER_MRECF_DATA_CRC_BAD      0x40000000
 #define HAMMER_MRECF_RECD_CRC_BAD      0x20000000
+#define HAMMER_MRECF_NODATA            0x10000000
 
 #define HAMMER_MREC_CRCOFF     (offsetof(struct hammer_ioc_mrecord_head, rec_size))
 #define HAMMER_MREC_HEADSIZE   sizeof(struct hammer_ioc_mrecord_head)
index 05e12a0..b7f81d4 100644 (file)
@@ -240,9 +240,18 @@ retry:
                 *
                 * CRC errors on data are reported but passed through,
                 * but the data must be washed by the user program.
+                *
+                * If userland just wants the btree records it can
+                * request that bulk data not be returned.  This is
+                * use during mirror-stream histogram generation.
                 */
                mrec_flags = 0;
                data_len = (elm->data_offset) ? elm->data_len : 0;
+               if (data_len &&
+                   (mirror->head.flags & HAMMER_IOC_MIRROR_NODATA)) {
+                       data_len = 0;
+                       mrec_flags |= HAMMER_MRECF_NODATA;
+               }
                if (data_len) {
                        error = hammer_btree_extract(&cursor,
                                                     HAMMER_CURSOR_GET_DATA);
@@ -438,9 +447,13 @@ hammer_ioc_mirror_write(hammer_transaction_t trans, hammer_inode_t ip,
                        if (error == 0)
                                error = hammer_ioc_mirror_write_rec(&cursor, &mrec.rec, mirror, localization, uptr + sizeof(mrec.rec));
                        break;
+               case HAMMER_MREC_TYPE_REC_NODATA:
                case HAMMER_MREC_TYPE_REC_BADCRC:
                        /*
                         * Records with bad data payloads are ignored XXX.
+                        * Records with no data payload have to be skipped
+                        * (they shouldn't have been written in the first
+                        * place).
                         */
                        if (mrec.head.rec_size < sizeof(mrec.rec))
                                error = EINVAL;