Print this page
4185 New hash algorithm support


 963                     NULL, MUTEX_DEFAULT, NULL);
 964         }
 965 }
 966 
 967 #define ARC_MINTIME     (hz>>4) /* 62 ms */
 968 
 969 static void
 970 arc_cksum_verify(arc_buf_t *buf)
 971 {
 972         zio_cksum_t zc;
 973 
 974         if (!(zfs_flags & ZFS_DEBUG_MODIFY))
 975                 return;
 976 
 977         mutex_enter(&buf->b_hdr->b_freeze_lock);
 978         if (buf->b_hdr->b_freeze_cksum == NULL ||
 979             (buf->b_hdr->b_flags & ARC_IO_ERROR)) {
 980                 mutex_exit(&buf->b_hdr->b_freeze_lock);
 981                 return;
 982         }
 983         fletcher_2_native(buf->b_data, buf->b_hdr->b_size, &zc);
 984         if (!ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc))
 985                 panic("buffer modified while frozen!");
 986         mutex_exit(&buf->b_hdr->b_freeze_lock);
 987 }
 988 
 989 static int
 990 arc_cksum_equal(arc_buf_t *buf)
 991 {
 992         zio_cksum_t zc;
 993         int equal;
 994 
 995         mutex_enter(&buf->b_hdr->b_freeze_lock);
 996         fletcher_2_native(buf->b_data, buf->b_hdr->b_size, &zc);
 997         equal = ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc);
 998         mutex_exit(&buf->b_hdr->b_freeze_lock);
 999 
1000         return (equal);
1001 }
1002 
1003 static void
1004 arc_cksum_compute(arc_buf_t *buf, boolean_t force)
1005 {
1006         if (!force && !(zfs_flags & ZFS_DEBUG_MODIFY))
1007                 return;
1008 
1009         mutex_enter(&buf->b_hdr->b_freeze_lock);
1010         if (buf->b_hdr->b_freeze_cksum != NULL) {
1011                 mutex_exit(&buf->b_hdr->b_freeze_lock);
1012                 return;
1013         }
1014         buf->b_hdr->b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), KM_SLEEP);
1015         fletcher_2_native(buf->b_data, buf->b_hdr->b_size,
1016             buf->b_hdr->b_freeze_cksum);
1017         mutex_exit(&buf->b_hdr->b_freeze_lock);
1018         arc_buf_watch(buf);
1019 }
1020 
1021 #ifndef _KERNEL
1022 typedef struct procctl {
1023         long cmd;
1024         prwatch_t prwatch;
1025 } procctl_t;
1026 #endif
1027 
1028 /* ARGSUSED */
1029 static void
1030 arc_buf_unwatch(arc_buf_t *buf)
1031 {
1032 #ifndef _KERNEL
1033         if (arc_watch) {
1034                 int result;
1035                 procctl_t ctl;




 963                     NULL, MUTEX_DEFAULT, NULL);
 964         }
 965 }
 966 
 967 #define ARC_MINTIME     (hz>>4) /* 62 ms */
 968 
 969 static void
 970 arc_cksum_verify(arc_buf_t *buf)
 971 {
 972         zio_cksum_t zc;
 973 
 974         if (!(zfs_flags & ZFS_DEBUG_MODIFY))
 975                 return;
 976 
 977         mutex_enter(&buf->b_hdr->b_freeze_lock);
 978         if (buf->b_hdr->b_freeze_cksum == NULL ||
 979             (buf->b_hdr->b_flags & ARC_IO_ERROR)) {
 980                 mutex_exit(&buf->b_hdr->b_freeze_lock);
 981                 return;
 982         }
 983         fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, NULL, &zc);
 984         if (!ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc))
 985                 panic("buffer modified while frozen!");
 986         mutex_exit(&buf->b_hdr->b_freeze_lock);
 987 }
 988 
 989 static int
 990 arc_cksum_equal(arc_buf_t *buf)
 991 {
 992         zio_cksum_t zc;
 993         int equal;
 994 
 995         mutex_enter(&buf->b_hdr->b_freeze_lock);
 996         fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, NULL, &zc);
 997         equal = ZIO_CHECKSUM_EQUAL(*buf->b_hdr->b_freeze_cksum, zc);
 998         mutex_exit(&buf->b_hdr->b_freeze_lock);
 999 
1000         return (equal);
1001 }
1002 
1003 static void
1004 arc_cksum_compute(arc_buf_t *buf, boolean_t force)
1005 {
1006         if (!force && !(zfs_flags & ZFS_DEBUG_MODIFY))
1007                 return;
1008 
1009         mutex_enter(&buf->b_hdr->b_freeze_lock);
1010         if (buf->b_hdr->b_freeze_cksum != NULL) {
1011                 mutex_exit(&buf->b_hdr->b_freeze_lock);
1012                 return;
1013         }
1014         buf->b_hdr->b_freeze_cksum = kmem_alloc(sizeof (zio_cksum_t), KM_SLEEP);
1015         fletcher_2_native(buf->b_data, buf->b_hdr->b_size, NULL, NULL,
1016             buf->b_hdr->b_freeze_cksum);
1017         mutex_exit(&buf->b_hdr->b_freeze_lock);
1018         arc_buf_watch(buf);
1019 }
1020 
1021 #ifndef _KERNEL
1022 typedef struct procctl {
1023         long cmd;
1024         prwatch_t prwatch;
1025 } procctl_t;
1026 #endif
1027 
1028 /* ARGSUSED */
1029 static void
1030 arc_buf_unwatch(arc_buf_t *buf)
1031 {
1032 #ifndef _KERNEL
1033         if (arc_watch) {
1034                 int result;
1035                 procctl_t ctl;