2 * Copyright (c) 2009 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com> and
6 * Michael Neumann <mneumann@ntecs.de>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include <sys/fcntl.h>
39 #include <sys/nlookup.h>
45 hammer_setup_device(struct vnode **devvpp, const char *dev_path, int ronly);
48 hammer_close_device(struct vnode **devvpp, int ronly);
51 hammer_format_volume_header(struct hammer_mount *hmp, struct vnode *devvp,
52 const char *vol_name, int vol_no, int vol_count,
53 int64_t vol_size, int64_t boot_area_size, int64_t mem_area_size);
56 hammer_clear_volume_header(struct vnode *devvp);
58 struct bigblock_stat {
59 uint64_t total_bigblocks;
60 uint64_t total_free_bigblocks;
65 hammer_format_freemap(hammer_transaction_t trans, hammer_volume_t volume,
66 struct bigblock_stat *stat);
69 hammer_free_freemap(hammer_transaction_t trans, hammer_volume_t volume,
70 struct bigblock_stat *stat);
73 hammer_ioc_volume_add(hammer_transaction_t trans, hammer_inode_t ip,
74 struct hammer_ioc_volume *ioc)
76 struct hammer_mount *hmp = trans->hmp;
77 struct mount *mp = hmp->mp;
78 hammer_volume_t volume;
81 if (mp->mnt_flag & MNT_RDONLY) {
82 kprintf("Cannot add volume to read-only HAMMER filesystem\n");
86 if (hmp->nvolumes + 1 >= HAMMER_MAX_VOLUMES) {
87 kprintf("Max number of HAMMER volumes exceeded\n");
91 if (hammer_lock_ex_try(&hmp->volume_lock) != 0) {
92 kprintf("Another volume operation is in progress!\n");
97 * Find an unused volume number.
100 while (free_vol_no < HAMMER_MAX_VOLUMES &&
101 RB_LOOKUP(hammer_vol_rb_tree, &hmp->rb_vols_root, free_vol_no)) {
104 if (free_vol_no >= HAMMER_MAX_VOLUMES) {
105 kprintf("Max number of HAMMER volumes exceeded\n");
106 hammer_unlock(&hmp->volume_lock);
110 struct vnode *devvp = NULL;
111 error = hammer_setup_device(&devvp, ioc->device_name, 0);
115 error = hammer_format_volume_header(
118 hmp->rootvol->ondisk->vol_name,
124 hammer_close_device(&devvp, 0);
128 error = hammer_install_volume(hmp, ioc->device_name, NULL);
132 hammer_sync_lock_sh(trans);
133 hammer_lock_ex(&hmp->blkmap_lock);
138 * Set each volumes new value of the vol_count field.
140 for (int vol_no = 0; vol_no < HAMMER_MAX_VOLUMES; ++vol_no) {
141 volume = hammer_get_volume(hmp, vol_no, &error);
142 if (volume == NULL && error == ENOENT) {
144 * Skip unused volume numbers
149 KKASSERT(volume != NULL && error == 0);
150 hammer_modify_volume_field(trans, volume, vol_count);
151 volume->ondisk->vol_count = hmp->nvolumes;
152 hammer_modify_volume_done(volume);
155 * Only changes to the header of the root volume
156 * are automatically flushed to disk. For all
157 * other volumes that we modify we do it here.
159 * No interlock is needed, volume buffers are not
160 * messed with by bioops.
162 if (volume != trans->rootvol && volume->io.modified) {
163 hammer_crc_set_volume(volume->ondisk);
164 hammer_io_flush(&volume->io, 0);
167 hammer_rel_volume(volume, 0);
170 volume = hammer_get_volume(hmp, free_vol_no, &error);
171 KKASSERT(volume != NULL && error == 0);
173 struct bigblock_stat stat;
174 error = hammer_format_freemap(trans, volume, &stat);
175 KKASSERT(error == 0);
178 * Increase the total number of bigblocks and update stat/vstat totals.
180 hammer_modify_volume_field(trans, trans->rootvol,
181 vol0_stat_bigblocks);
182 trans->rootvol->ondisk->vol0_stat_bigblocks += stat.total_bigblocks;
183 hammer_modify_volume_done(trans->rootvol);
184 mp->mnt_stat.f_blocks += trans->rootvol->ondisk->vol0_stat_bigblocks *
185 (HAMMER_LARGEBLOCK_SIZE / HAMMER_BUFSIZE);
186 mp->mnt_vstat.f_blocks += trans->rootvol->ondisk->vol0_stat_bigblocks *
187 (HAMMER_LARGEBLOCK_SIZE / HAMMER_BUFSIZE);
190 * Increase the number of free bigblocks
191 * (including the copy in hmp)
193 hammer_modify_volume_field(trans, trans->rootvol,
194 vol0_stat_freebigblocks);
195 trans->rootvol->ondisk->vol0_stat_freebigblocks += stat.total_free_bigblocks;
196 hmp->copy_stat_freebigblocks =
197 trans->rootvol->ondisk->vol0_stat_freebigblocks;
198 hammer_modify_volume_done(trans->rootvol);
200 hammer_rel_volume(volume, 0);
202 hammer_unlock(&hmp->blkmap_lock);
203 hammer_sync_unlock(trans);
205 KKASSERT(error == 0);
207 hammer_unlock(&hmp->volume_lock);
209 kprintf("An error occurred: %d\n", error);
218 hammer_ioc_volume_del(hammer_transaction_t trans, hammer_inode_t ip,
219 struct hammer_ioc_volume *ioc)
221 struct hammer_mount *hmp = trans->hmp;
222 struct mount *mp = hmp->mp;
223 hammer_volume_t volume;
226 if (mp->mnt_flag & MNT_RDONLY) {
227 kprintf("Cannot del volume from read-only HAMMER filesystem\n");
231 if (hammer_lock_ex_try(&hmp->volume_lock) != 0) {
232 kprintf("Another volume operation is in progress!\n");
239 * find volume by volname
241 for (int vol_no = 0; vol_no < HAMMER_MAX_VOLUMES; ++vol_no) {
242 volume = hammer_get_volume(hmp, vol_no, &error);
243 if (volume == NULL && error == ENOENT) {
245 * Skip unused volume numbers
250 KKASSERT(volume != NULL && error == 0);
251 if (strcmp(volume->vol_name, ioc->device_name) == 0) {
254 hammer_rel_volume(volume, 0);
258 if (volume == NULL) {
259 kprintf("Couldn't find volume\n");
264 if (volume == trans->rootvol) {
265 kprintf("Cannot remove root-volume\n");
266 hammer_rel_volume(volume, 0);
275 hmp->volume_to_remove = volume->vol_no;
277 struct hammer_ioc_reblock reblock;
278 bzero(&reblock, sizeof(reblock));
280 reblock.key_beg.localization = HAMMER_MIN_LOCALIZATION;
281 reblock.key_beg.obj_id = HAMMER_MIN_OBJID;
282 reblock.key_end.localization = HAMMER_MAX_LOCALIZATION;
283 reblock.key_end.obj_id = HAMMER_MAX_OBJID;
284 reblock.head.flags = HAMMER_IOC_DO_FLAGS;
285 reblock.free_level = 0;
287 error = hammer_ioc_reblock(trans, ip, &reblock);
289 if (reblock.head.flags & HAMMER_IOC_HEAD_INTR) {
294 if (error == EINTR) {
295 kprintf("reblock was interrupted\n");
297 kprintf("reblock failed: %d\n", error);
299 hmp->volume_to_remove = -1;
300 hammer_rel_volume(volume, 0);
308 while (hammer_flusher_haswork(hmp)) {
309 hammer_flusher_sync(hmp);
313 kprintf("HAMMER: flushing.");
316 tsleep(&count, 0, "hmrufl", hz);
319 kprintf("giving up");
325 hammer_sync_lock_sh(trans);
326 hammer_lock_ex(&hmp->blkmap_lock);
329 * We use stat later to update rootvol's bigblock stats
331 struct bigblock_stat stat;
332 error = hammer_free_freemap(trans, volume, &stat);
334 kprintf("Failed to free volume. Volume not empty!\n");
335 hmp->volume_to_remove = -1;
336 hammer_rel_volume(volume, 0);
337 hammer_unlock(&hmp->blkmap_lock);
338 hammer_sync_unlock(trans);
342 hmp->volume_to_remove = -1;
344 hammer_rel_volume(volume, 0);
349 RB_SCAN(hammer_buf_rb_tree, &hmp->rb_bufs_root, NULL,
350 hammer_unload_buffer, volume);
352 error = hammer_unload_volume(volume, NULL);
354 kprintf("Failed to unload volume\n");
355 hammer_unlock(&hmp->blkmap_lock);
356 hammer_sync_unlock(trans);
364 * Set each volume's new value of the vol_count field.
366 for (int vol_no = 0; vol_no < HAMMER_MAX_VOLUMES; ++vol_no) {
367 volume = hammer_get_volume(hmp, vol_no, &error);
368 if (volume == NULL && error == ENOENT) {
370 * Skip unused volume numbers
376 KKASSERT(volume != NULL && error == 0);
377 hammer_modify_volume_field(trans, volume, vol_count);
378 volume->ondisk->vol_count = hmp->nvolumes;
379 hammer_modify_volume_done(volume);
382 * Only changes to the header of the root volume
383 * are automatically flushed to disk. For all
384 * other volumes that we modify we do it here.
386 * No interlock is needed, volume buffers are not
387 * messed with by bioops.
389 if (volume != trans->rootvol && volume->io.modified) {
390 hammer_crc_set_volume(volume->ondisk);
391 hammer_io_flush(&volume->io, 0);
394 hammer_rel_volume(volume, 0);
398 * Update the total number of bigblocks
400 hammer_modify_volume_field(trans, trans->rootvol,
401 vol0_stat_bigblocks);
402 trans->rootvol->ondisk->vol0_stat_bigblocks -= stat.total_bigblocks;
403 hammer_modify_volume_done(trans->rootvol);
406 * Update the number of free bigblocks
407 * (including the copy in hmp)
409 hammer_modify_volume_field(trans, trans->rootvol,
410 vol0_stat_freebigblocks);
411 trans->rootvol->ondisk->vol0_stat_freebigblocks -= stat.total_free_bigblocks;
412 hmp->copy_stat_freebigblocks =
413 trans->rootvol->ondisk->vol0_stat_freebigblocks;
414 hammer_modify_volume_done(trans->rootvol);
417 hammer_unlock(&hmp->blkmap_lock);
418 hammer_sync_unlock(trans);
421 * Erase the volume header of the removed device.
423 * This is to not accidentally mount the volume again.
425 struct vnode *devvp = NULL;
426 error = hammer_setup_device(&devvp, ioc->device_name, 0);
428 kprintf("Failed to open device: %s\n", ioc->device_name);
432 error = hammer_clear_volume_header(devvp);
434 kprintf("Failed to clear volume header of device: %s\n",
438 hammer_close_device(&devvp, 0);
440 KKASSERT(error == 0);
442 hammer_unlock(&hmp->volume_lock);
448 hammer_ioc_volume_list(hammer_transaction_t trans, hammer_inode_t ip,
449 struct hammer_ioc_volume_list *ioc)
451 struct hammer_mount *hmp = trans->hmp;
452 hammer_volume_t volume;
456 for (i = 0, cnt = 0; i < HAMMER_MAX_VOLUMES && cnt < ioc->nvols; i++) {
457 volume = hammer_get_volume(hmp, i, &error);
458 if (volume == NULL && error == ENOENT) {
462 KKASSERT(volume != NULL && error == 0);
464 len = strlen(volume->vol_name) + 1;
465 KKASSERT(len <= MAXPATHLEN);
467 error = copyout(volume->vol_name, ioc->vols[cnt].device_name,
470 hammer_rel_volume(volume, 0);
474 hammer_rel_volume(volume, 0);
482 * Iterate over all usable L1 entries of the volume and
483 * the corresponding L2 entries.
486 hammer_iterate_l1l2_entries(hammer_transaction_t trans, hammer_volume_t volume,
487 int (*callback)(hammer_transaction_t, hammer_volume_t, hammer_buffer_t*,
488 struct hammer_blockmap_layer1*, struct hammer_blockmap_layer2*,
489 hammer_off_t, hammer_off_t, void*),
492 struct hammer_mount *hmp = trans->hmp;
493 hammer_blockmap_t freemap = &hmp->blockmap[HAMMER_ZONE_FREEMAP_INDEX];
494 hammer_buffer_t buffer = NULL;
497 hammer_off_t phys_off;
498 hammer_off_t block_off;
499 hammer_off_t layer1_off;
500 hammer_off_t layer2_off;
501 hammer_off_t aligned_buf_end_off;
502 struct hammer_blockmap_layer1 *layer1;
503 struct hammer_blockmap_layer2 *layer2;
506 * Calculate the usable size of the volume, which
507 * must be aligned at a bigblock (8 MB) boundary.
509 aligned_buf_end_off = (HAMMER_ENCODE_RAW_BUFFER(volume->ondisk->vol_no,
510 (volume->ondisk->vol_buf_end - volume->ondisk->vol_buf_beg)
511 & ~HAMMER_LARGEBLOCK_MASK64));
514 * Iterate the volume's address space in chunks of 4 TB, where each
515 * chunk consists of at least one physically available 8 MB bigblock.
517 * For each chunk we need one L1 entry and one L2 bigblock.
518 * We use the first bigblock of each chunk as L2 block.
520 for (phys_off = HAMMER_ENCODE_RAW_BUFFER(volume->ondisk->vol_no, 0);
521 phys_off < aligned_buf_end_off;
522 phys_off += HAMMER_BLOCKMAP_LAYER2) {
524 block_off < HAMMER_BLOCKMAP_LAYER2;
525 block_off += HAMMER_LARGEBLOCK_SIZE) {
526 layer2_off = phys_off +
527 HAMMER_BLOCKMAP_LAYER2_OFFSET(block_off);
528 layer2 = hammer_bread(hmp, layer2_off, &error, &buffer);
532 error = callback(trans, volume, &buffer, NULL,
533 layer2, phys_off, block_off, data);
538 layer1_off = freemap->phys_offset +
539 HAMMER_BLOCKMAP_LAYER1_OFFSET(phys_off);
540 layer1 = hammer_bread(hmp, layer1_off, &error, &buffer);
544 error = callback(trans, volume, &buffer, layer1, NULL,
552 hammer_rel_buffer(buffer, 0);
561 format_callback(hammer_transaction_t trans, hammer_volume_t volume,
562 hammer_buffer_t *bufferp,
563 struct hammer_blockmap_layer1 *layer1,
564 struct hammer_blockmap_layer2 *layer2,
565 hammer_off_t phys_off,
566 hammer_off_t block_off,
569 struct bigblock_stat *stat = (struct bigblock_stat*)data;
572 * Calculate the usable size of the volume, which must be aligned
573 * at a bigblock (8 MB) boundary.
575 hammer_off_t aligned_buf_end_off;
576 aligned_buf_end_off = (HAMMER_ENCODE_RAW_BUFFER(volume->ondisk->vol_no,
577 (volume->ondisk->vol_buf_end - volume->ondisk->vol_buf_beg)
578 & ~HAMMER_LARGEBLOCK_MASK64));
581 KKASSERT(layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL);
583 hammer_modify_buffer(trans, *bufferp, layer1, sizeof(*layer1));
584 bzero(layer1, sizeof(*layer1));
585 layer1->phys_offset = phys_off;
586 layer1->blocks_free = stat->counter;
587 layer1->layer1_crc = crc32(layer1, HAMMER_LAYER1_CRCSIZE);
588 hammer_modify_buffer_done(*bufferp);
590 stat->total_free_bigblocks += stat->counter;
591 stat->counter = 0; /* reset */
593 hammer_modify_buffer(trans, *bufferp, layer2, sizeof(*layer2));
594 bzero(layer2, sizeof(*layer2));
596 if (block_off == 0) {
598 * The first entry represents the L2 bigblock itself.
600 layer2->zone = HAMMER_ZONE_FREEMAP_INDEX;
601 layer2->append_off = HAMMER_LARGEBLOCK_SIZE;
602 layer2->bytes_free = 0;
603 ++stat->total_bigblocks;
604 } else if (phys_off + block_off < aligned_buf_end_off) {
609 layer2->append_off = 0;
610 layer2->bytes_free = HAMMER_LARGEBLOCK_SIZE;
611 ++stat->total_bigblocks;
615 * Bigblock outside of physically available
618 layer2->zone = HAMMER_ZONE_UNAVAIL_INDEX;
619 layer2->append_off = HAMMER_LARGEBLOCK_SIZE;
620 layer2->bytes_free = 0;
623 layer2->entry_crc = crc32(layer2, HAMMER_LAYER2_CRCSIZE);
624 hammer_modify_buffer_done(*bufferp);
633 hammer_format_freemap(hammer_transaction_t trans, hammer_volume_t volume,
634 struct bigblock_stat *stat)
636 stat->total_bigblocks = 0;
637 stat->total_free_bigblocks = 0;
639 return hammer_iterate_l1l2_entries(trans, volume, format_callback, stat);
643 free_callback(hammer_transaction_t trans, hammer_volume_t volume __unused,
644 hammer_buffer_t *bufferp,
645 struct hammer_blockmap_layer1 *layer1,
646 struct hammer_blockmap_layer2 *layer2,
647 hammer_off_t phys_off,
648 hammer_off_t block_off __unused,
651 struct bigblock_stat *stat = (struct bigblock_stat*)data;
654 * No modifications to ondisk structures
656 int testonly = (stat == NULL);
659 if (layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL) {
661 * This layer1 entry is already free.
666 KKASSERT((int)HAMMER_VOL_DECODE(layer1->phys_offset) ==
667 trans->hmp->volume_to_remove);
675 hammer_modify_buffer(trans, *bufferp, layer1, sizeof(*layer1));
676 bzero(layer1, sizeof(*layer1));
677 layer1->phys_offset = HAMMER_BLOCKMAP_UNAVAIL;
678 layer1->layer1_crc = crc32(layer1, HAMMER_LAYER1_CRCSIZE);
679 hammer_modify_buffer_done(*bufferp);
683 if (layer2->zone == HAMMER_ZONE_UNAVAIL_INDEX) {
687 if (layer2->zone == HAMMER_ZONE_FREEMAP_INDEX) {
689 ++stat->total_bigblocks;
694 if (layer2->append_off == 0 &&
695 layer2->bytes_free == HAMMER_LARGEBLOCK_SIZE) {
697 ++stat->total_bigblocks;
698 ++stat->total_free_bigblocks;
704 * We found a layer2 entry that is not empty!
715 hammer_free_freemap(hammer_transaction_t trans, hammer_volume_t volume,
716 struct bigblock_stat *stat)
720 stat->total_bigblocks = 0;
721 stat->total_free_bigblocks = 0;
724 error = hammer_iterate_l1l2_entries(trans, volume, free_callback, NULL);
728 error = hammer_iterate_l1l2_entries(trans, volume, free_callback, stat);
732 /************************************************************************
734 ************************************************************************
738 hammer_setup_device(struct vnode **devvpp, const char *dev_path, int ronly)
741 struct nlookupdata nd;
744 * Get the device vnode
746 if (*devvpp == NULL) {
747 error = nlookup_init(&nd, dev_path, UIO_SYSSPACE, NLC_FOLLOW);
749 error = nlookup(&nd);
751 error = cache_vref(&nd.nl_nch, nd.nl_cred, devvpp);
758 if (vn_isdisk(*devvpp, &error)) {
759 error = vfs_mountedon(*devvpp);
762 if (error == 0 && vcount(*devvpp) > 0)
765 vn_lock(*devvpp, LK_EXCLUSIVE | LK_RETRY);
766 error = vinvalbuf(*devvpp, V_SAVE, 0, 0);
768 error = VOP_OPEN(*devvpp,
769 (ronly ? FREAD : FREAD|FWRITE),
774 if (error && *devvpp) {
782 hammer_close_device(struct vnode **devvpp, int ronly)
785 vn_lock(*devvpp, LK_EXCLUSIVE | LK_RETRY);
786 vinvalbuf(*devvpp, ronly ? 0 : V_SAVE, 0, 0);
787 VOP_CLOSE(*devvpp, (ronly ? FREAD : FREAD|FWRITE));
795 hammer_format_volume_header(struct hammer_mount *hmp, struct vnode *devvp,
796 const char *vol_name, int vol_no, int vol_count,
797 int64_t vol_size, int64_t boot_area_size, int64_t mem_area_size)
799 struct buf *bp = NULL;
800 struct hammer_volume_ondisk *ondisk;
804 * Extract the volume number from the volume header and do various
807 KKASSERT(HAMMER_BUFSIZE >= sizeof(struct hammer_volume_ondisk));
808 error = bread(devvp, 0LL, HAMMER_BUFSIZE, &bp);
809 if (error || bp->b_bcount < sizeof(struct hammer_volume_ondisk))
812 ondisk = (struct hammer_volume_ondisk*) bp->b_data;
815 * Note that we do NOT allow to use a device that contains
816 * a valid HAMMER signature. It has to be cleaned up with dd
819 if (ondisk->vol_signature == HAMMER_FSBUF_VOLUME) {
820 kprintf("hammer_volume_add: Formatting of valid HAMMER volume "
821 "%s denied. Erase with dd!\n", vol_name);
826 bzero(ondisk, sizeof(struct hammer_volume_ondisk));
827 ksnprintf(ondisk->vol_name, sizeof(ondisk->vol_name), "%s", vol_name);
828 ondisk->vol_fstype = hmp->rootvol->ondisk->vol_fstype;
829 ondisk->vol_signature = HAMMER_FSBUF_VOLUME;
830 ondisk->vol_fsid = hmp->fsid;
831 ondisk->vol_rootvol = hmp->rootvol->vol_no;
832 ondisk->vol_no = vol_no;
833 ondisk->vol_count = vol_count;
834 ondisk->vol_version = hmp->version;
837 * Reserve space for (future) header junk, setup our poor-man's
838 * bigblock allocator.
840 int64_t vol_alloc = HAMMER_BUFSIZE * 16;
842 ondisk->vol_bot_beg = vol_alloc;
843 vol_alloc += boot_area_size;
844 ondisk->vol_mem_beg = vol_alloc;
845 vol_alloc += mem_area_size;
848 * The remaining area is the zone 2 buffer allocation area. These
851 ondisk->vol_buf_beg = vol_alloc;
852 ondisk->vol_buf_end = vol_size & ~(int64_t)HAMMER_BUFMASK;
854 if (ondisk->vol_buf_end < ondisk->vol_buf_beg) {
855 kprintf("volume %d %s is too small to hold the volume header",
856 ondisk->vol_no, ondisk->vol_name);
861 ondisk->vol_nblocks = (ondisk->vol_buf_end - ondisk->vol_buf_beg) /
863 ondisk->vol_blocksize = HAMMER_BUFSIZE;
866 * Write volume header to disk
878 * Invalidates the volume header. Used by volume-del.
881 hammer_clear_volume_header(struct vnode *devvp)
883 struct buf *bp = NULL;
884 struct hammer_volume_ondisk *ondisk;
887 KKASSERT(HAMMER_BUFSIZE >= sizeof(struct hammer_volume_ondisk));
888 error = bread(devvp, 0LL, HAMMER_BUFSIZE, &bp);
889 if (error || bp->b_bcount < sizeof(struct hammer_volume_ondisk))
892 ondisk = (struct hammer_volume_ondisk*) bp->b_data;
893 bzero(ondisk, sizeof(struct hammer_volume_ondisk));