From dd94f1b1ad357fec1cb4404c99bb7ed9ba6460d1 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 24 Jun 2008 17:38:17 +0000 Subject: [PATCH] HAMMER 58B/Many: Revamp ioctls, add non-monotonic timestamps, mirroring * Revamp most of HAMMER's ioctl structures with an eye towards future enhancements. * Adjust on-media structures to include a non-monotonic creation and deletion timestamps. Since the transaction id no longer translates to a timestamp adding explicit timestamps allows the 'hammer history' and 'undo' utilities to still display timestamps for the change history. * Start working on the mirroring support ioctls. --- sys/vfs/hammer/hammer.h | 3 +- sys/vfs/hammer/hammer_btree.h | 11 ++- sys/vfs/hammer/hammer_inode.c | 9 +- sys/vfs/hammer/hammer_ioctl.c | 20 +++-- sys/vfs/hammer/hammer_ioctl.h | 75 ++++++++++------ sys/vfs/hammer/hammer_mirror.c | 133 ++++++++++++++++++++++++++++ sys/vfs/hammer/hammer_object.c | 6 +- sys/vfs/hammer/hammer_prune.c | 35 ++++---- sys/vfs/hammer/hammer_reblock.c | 29 +++--- sys/vfs/hammer/hammer_transaction.c | 14 +-- sys/vfs/hammer/hammer_vfsops.c | 6 +- 11 files changed, 263 insertions(+), 78 deletions(-) create mode 100644 sys/vfs/hammer/hammer_mirror.c diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index f01e9b447b..3291f6e79c 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.91 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.92 2008/06/24 17:38:17 dillon Exp $ */ /* * This header file contains structures used internally by the HAMMERFS @@ -107,6 +107,7 @@ struct hammer_transaction { struct hammer_mount *hmp; hammer_tid_t tid; u_int64_t time; + u_int32_t time32; int sync_lock_refs; struct hammer_volume *rootvol; }; diff --git a/sys/vfs/hammer/hammer_btree.h b/sys/vfs/hammer/hammer_btree.h index a264b1f69a..ac5d266635 100644 --- a/sys/vfs/hammer/hammer_btree.h +++ b/sys/vfs/hammer/hammer_btree.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_btree.h,v 1.22 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_btree.h,v 1.23 2008/06/24 17:38:17 dillon Exp $ */ /* @@ -128,7 +128,7 @@ typedef struct hammer_base_elm *hammer_base_elm_t; #define HAMMER_LOCALIZE_PSEUDOFS_INC 0x00010000 #define HAMMER_MIN_LOCALIZATION 0x00000000U -#define HAMMER_MAX_LOCALIZATION 0xFFFFFFFFU +#define HAMMER_MAX_LOCALIZATION 0x0000FFFFU #define HAMMER_DEF_LOCALIZATION 0x00000000U /* @@ -148,11 +148,14 @@ struct hammer_btree_internal_elm { /* * Leaf B-Tree element (40 + 24 = 64 bytes). * - * A leaf element. + * NOTE: create_ts/delete_ts are not used by any core algorithms, they are + * used only by userland to present nominal real-time date strings + * to the user. */ struct hammer_btree_leaf_elm { struct hammer_base_elm base; - hammer_tid_t unused01; + u_int32_t create_ts; + u_int32_t delete_ts; hammer_off_t data_offset; int32_t data_len; hammer_crc_t data_crc; diff --git a/sys/vfs/hammer/hammer_inode.c b/sys/vfs/hammer/hammer_inode.c index 254f4271b1..2abfd5c509 100644 --- a/sys/vfs/hammer/hammer_inode.c +++ b/sys/vfs/hammer/hammer_inode.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.83 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.84 2008/06/24 17:38:17 dillon Exp $ */ #include "hammer.h" @@ -677,6 +677,7 @@ retry: record->leaf = ip->sync_ino_leaf; record->leaf.base.create_tid = trans->tid; record->leaf.data_len = sizeof(ip->sync_ino_data); + record->leaf.create_ts = trans->time32; record->data = (void *)&ip->sync_ino_data; record->flags |= HAMMER_RECF_INTERLOCK_BE; for (;;) { @@ -1717,6 +1718,7 @@ hammer_sync_record_callback(hammer_record_t record, void *data) */ if (record->type != HAMMER_MEM_RECORD_DEL) record->leaf.base.create_tid = trans->tid; + record->leaf.create_ts = trans->time32; for (;;) { error = hammer_ip_sync_record_cursor(cursor, record); if (error != EDEADLK) @@ -1934,6 +1936,9 @@ hammer_sync_inode(hammer_inode_t ip) */ ip->ino_leaf.base.delete_tid = trans.tid; ip->sync_ino_leaf.base.delete_tid = trans.tid; + ip->ino_leaf.delete_ts = trans.time32; + ip->sync_ino_leaf.delete_ts = trans.time32; + /* * Adjust the inode count in the volume header @@ -2005,7 +2010,9 @@ hammer_sync_inode(hammer_inode_t ip) * copy of the inode record. */ ip->ino_leaf.base.create_tid = trans.tid; + ip->ino_leaf.create_ts = trans.time32; ip->sync_ino_leaf.base.create_tid = trans.tid; + ip->sync_ino_leaf.create_ts = trans.time32; ip->sync_flags |= HAMMER_INODE_DDIRTY; break; } diff --git a/sys/vfs/hammer/hammer_ioctl.c b/sys/vfs/hammer/hammer_ioctl.c index fde75017dc..563644d036 100644 --- a/sys/vfs/hammer/hammer_ioctl.c +++ b/sys/vfs/hammer/hammer_ioctl.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_ioctl.c,v 1.22 2008/06/23 07:31:14 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_ioctl.c,v 1.23 2008/06/24 17:38:17 dillon Exp $ */ #include "hammer.h" @@ -222,6 +222,8 @@ static void add_history(hammer_inode_t ip, struct hammer_ioc_history *hist, hammer_btree_elm_t elm) { + int i; + if (elm->base.btype != HAMMER_BTREE_TYPE_RECORD) return; if ((hist->head.flags & HAMMER_IOC_HISTORY_ATKEY) && @@ -270,8 +272,9 @@ add_history(hammer_inode_t ip, struct hammer_ioc_history *hist, /* * Add create_tid if it is in-bounds. */ - if ((hist->count == 0 || - elm->leaf.base.create_tid != hist->tid_ary[hist->count - 1]) && + i = hist->count; + if ((i == 0 || + elm->leaf.base.create_tid != hist->hist_ary[i - 1].tid) && elm->leaf.base.create_tid >= hist->beg_tid && elm->leaf.base.create_tid < hist->end_tid) { if (hist->count == HAMMER_MAX_HISTORY_ELMS) { @@ -279,7 +282,9 @@ add_history(hammer_inode_t ip, struct hammer_ioc_history *hist, hist->head.flags |= HAMMER_IOC_HISTORY_NEXT_TID; return; } - hist->tid_ary[hist->count++] = elm->leaf.base.create_tid; + hist->hist_ary[i].tid = elm->leaf.base.create_tid; + hist->hist_ary[i].time32 = elm->leaf.create_ts; + ++hist->count; } /* @@ -291,15 +296,18 @@ add_history(hammer_inode_t ip, struct hammer_ioc_history *hist, * [ ] * [ ] */ + i = hist->count; if (elm->leaf.base.delete_tid && elm->leaf.base.delete_tid >= hist->beg_tid && elm->leaf.base.delete_tid < hist->end_tid) { - if (hist->count == HAMMER_MAX_HISTORY_ELMS) { + if (i == HAMMER_MAX_HISTORY_ELMS) { hist->nxt_tid = elm->leaf.base.delete_tid; hist->head.flags |= HAMMER_IOC_HISTORY_NEXT_TID; return; } - hist->tid_ary[hist->count++] = elm->leaf.base.delete_tid; + hist->hist_ary[i].tid = elm->leaf.base.delete_tid; + hist->hist_ary[i].time32 = elm->leaf.delete_ts; + ++hist->count; } } diff --git a/sys/vfs/hammer/hammer_ioctl.h b/sys/vfs/hammer/hammer_ioctl.h index 2b2250b9b1..f0e1e3c1e8 100644 --- a/sys/vfs/hammer/hammer_ioctl.h +++ b/sys/vfs/hammer/hammer_ioctl.h @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_ioctl.h,v 1.13 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_ioctl.h,v 1.14 2008/06/24 17:38:17 dillon Exp $ */ /* * HAMMER ioctl's. This file can be #included from userland @@ -84,14 +84,11 @@ struct hammer_ioc_prune { struct hammer_ioc_head head; int nelms; int reserved01; - u_int32_t beg_localization; - u_int32_t cur_localization; - u_int32_t end_localization; - u_int32_t reserved03; - int64_t beg_obj_id; - int64_t cur_obj_id; - int64_t cur_key; - int64_t end_obj_id; /* (range-exclusive) */ + + struct hammer_base_elm key_beg; /* stop forward scan (reverse scan) */ + struct hammer_base_elm key_end; /* start forward scan (reverse scan) */ + struct hammer_base_elm key_cur; /* scan interruption point */ + int64_t stat_scanrecords;/* number of records scanned */ int64_t stat_rawrecords; /* number of raw records pruned */ int64_t stat_dirrecords; /* number of dir records pruned */ @@ -131,6 +128,12 @@ struct hammer_ioc_prune { #define HAMMER_MAX_HISTORY_ELMS 64 +typedef struct hammer_ioc_hist_entry { + hammer_tid_t tid; + u_int32_t time32; + u_int32_t unused; +} *hammer_ioc_hist_entry_t; + struct hammer_ioc_history { struct hammer_ioc_head head; int64_t obj_id; @@ -141,7 +144,7 @@ struct hammer_ioc_history { int64_t nxt_key; int count; int reserve01; - hammer_tid_t tid_ary[HAMMER_MAX_HISTORY_ELMS]; + struct hammer_ioc_hist_entry hist_ary[HAMMER_MAX_HISTORY_ELMS]; }; #define HAMMER_IOC_HISTORY_ATKEY 0x0001 @@ -158,14 +161,9 @@ struct hammer_ioc_reblock { int32_t free_level; /* 0 for maximum compaction */ u_int32_t reserved01; - u_int32_t beg_localization; - u_int32_t cur_localization; - u_int32_t end_localization; - u_int32_t reserved03; - - int64_t beg_obj_id; - int64_t cur_obj_id; /* Stopped at (interrupt) */ - int64_t end_obj_id; + struct hammer_base_elm key_beg; /* start forward scan */ + struct hammer_base_elm key_end; /* stop forward scan */ + struct hammer_base_elm key_cur; /* scan interruption point */ int64_t btree_count; /* B-Tree nodes checked */ int64_t record_count; /* Records checked */ @@ -182,7 +180,7 @@ struct hammer_ioc_reblock { }; /* - * HAMMER_IOC_SYNCTID + * HAMMERIOC_SYNCTID */ enum hammer_synctid_op { HAMMER_SYNCTID_NONE, /* no sync (TID will not be accurate) */ @@ -198,26 +196,49 @@ struct hammer_ioc_synctid { }; /* - * HAMMER_IOC_MAKE_PSEUDOFS + * HAMMERIOC_GET_PSEUDOFS */ -#define HAMMER_IOC_MAXPSEUDONAME 64 - -struct hammer_ioc_make_pseudofs { - struct hammer_ioc_head head; - char pseudoname[HAMMER_IOC_MAXPSEUDONAME]; -}; - struct hammer_ioc_get_pseudofs { struct hammer_ioc_head head; u_int32_t pseudoid; int masterid; }; +/* + * HAMMERIOC_MIRROR_READ/WRITE + */ +struct hammer_ioc_mirror_rw { + struct hammer_ioc_head head; + struct hammer_base_elm key_beg; /* start forward scan */ + struct hammer_base_elm key_end; /* stop forward scan */ + struct hammer_base_elm key_cur; /* interruption point */ + hammer_tid_t tid_beg; /* filter modification range */ + hammer_tid_t tid_end; /* filter modification range */ + void *ubuf; /* user buffer */ + int count; /* current size */ + int size; /* max size */ +}; + +typedef struct hammer_ioc_mrecord { + u_int32_t signature; /* signature for byte order */ + u_int32_t rec_size; + struct hammer_btree_leaf_elm leaf; + char data[8]; /* extended */ +} *hammer_ioc_mrecord_t; + +#define HAMMER_IOC_MIRROR_SIGNATURE 0x4dd97272U +#define HAMMER_IOC_MIRROR_SIGNATURE_REV 0x7272d94dU + +/* + * Ioctl cmd ids + */ #define HAMMERIOC_PRUNE _IOWR('h',1,struct hammer_ioc_prune) #define HAMMERIOC_GETHISTORY _IOWR('h',2,struct hammer_ioc_history) #define HAMMERIOC_REBLOCK _IOWR('h',3,struct hammer_ioc_reblock) #define HAMMERIOC_SYNCTID _IOWR('h',4,struct hammer_ioc_synctid) #define HAMMERIOC_GET_PSEUDOFS _IOR('h',6,struct hammer_ioc_get_pseudofs) +#define HAMMERIOC_MIRROR_READ _IOWR('h',7,struct hammer_ioc_mirror_rw) +#define HAMMERIOC_MIRROR_WRITE _IOWR('h',8,struct hammer_ioc_mirror_rw) #endif diff --git a/sys/vfs/hammer/hammer_mirror.c b/sys/vfs/hammer/hammer_mirror.c new file mode 100644 index 0000000000..76815a1b7c --- /dev/null +++ b/sys/vfs/hammer/hammer_mirror.c @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2008 The DragonFly Project. All rights reserved. + * + * This code is derived from software contributed to The DragonFly Project + * by Matthew Dillon + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of The DragonFly Project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific, prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $DragonFly: src/sys/vfs/hammer/hammer_mirror.c,v 1.1 2008/06/24 17:38:17 dillon Exp $ + */ +/* + * HAMMER mirroring ioctls - serialize and deserialize modifications made + * to a filesystem. + */ + +#include "hammer.h" + +int +hammer_ioc_mirror_read(hammer_transaction_t trans, hammer_inode_t ip, + struct hammer_ioc_mirror_rw *mirror) +{ + struct hammer_cursor cursor; + hammer_btree_elm_t elm; + int error; + + if ((mirror->key_beg.localization | mirror->key_end.localization) & + HAMMER_LOCALIZE_PSEUDOFS_MASK) { + return(EINVAL); + } + if (hammer_btree_cmp(&mirror->key_beg, &mirror->key_end) > 0) + return(EINVAL); + + mirror->key_cur = mirror->key_beg; + mirror->key_cur.localization += ip->obj_localization; + +retry: + error = hammer_init_cursor(trans, &cursor, NULL, NULL); + if (error) { + hammer_done_cursor(&cursor); + goto failed; + } + cursor.key_beg = mirror->key_cur; + cursor.key_end = mirror->key_end; + cursor.key_end.localization += ip->obj_localization; + + cursor.flags |= HAMMER_CURSOR_END_INCLUSIVE; + cursor.flags |= HAMMER_CURSOR_BACKEND; + + /* + * This flag allows the btree scan code to return internal nodes + * at every index, giving the mirroring code the ability to skip + * whole sub-trees based on mirror_tid. + */ + cursor.flags |= HAMMER_CURSOR_MIRRORING; + + error = hammer_btree_first(&cursor); + while (error == 0) { + /* + * Internal or Leaf node + */ + elm = &cursor.node->ondisk->elms[cursor.index]; + reblock->key_cur.obj_id = elm->base.obj_id; + reblock->key_cur.localization = elm->base.localization; + + /* + * Yield to more important tasks + */ + if ((error = hammer_signal_check(trans->hmp)) != 0) + break; + if (trans->hmp->sync_lock.wanted) { + tsleep(trans, 0, "hmrslo", hz / 10); + } + if (trans->hmp->locked_dirty_count + + trans->hmp->io_running_count > hammer_limit_dirtybufs) { + hammer_flusher_async(trans->hmp); + tsleep(trans, 0, "hmrslo", hz / 10); + } + +#if 0 + /* + * Acquiring the sync_lock prevents the operation from + * crossing a synchronization boundary. + * + * NOTE: cursor.node may have changed on return. + */ + hammer_sync_lock_sh(trans); + error = hammer_reblock_helper(reblock, &cursor, elm); + hammer_sync_unlock(trans); +#endif + if (error == 0) { + cursor.flags |= HAMMER_CURSOR_ATEDISK; + error = hammer_btree_iterate(&cursor); + } + } + if (error == ENOENT) + error = 0; + hammer_done_cursor(&cursor); + if (error == EDEADLK) + goto retry; + if (error == EINTR) { + reblock->head.flags |= HAMMER_IOC_HEAD_INTR; + error = 0; + } +failed: + mirror->key_cur.localization &= HAMMER_LOCALIZE_MASK; + return(error); +} + diff --git a/sys/vfs/hammer/hammer_object.c b/sys/vfs/hammer/hammer_object.c index 294d7e636b..ca071ee887 100644 --- a/sys/vfs/hammer/hammer_object.c +++ b/sys/vfs/hammer/hammer_object.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_object.c,v 1.74 2008/06/23 07:31:14 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_object.c,v 1.75 2008/06/24 17:38:17 dillon Exp $ */ #include "hammer.h" @@ -1853,9 +1853,9 @@ hammer_ip_delete_record(hammer_cursor_t cursor, hammer_inode_t ip, if (error == 0) { elm = &cursor->node->ondisk->elms[cursor->index]; hammer_modify_node(cursor->trans, cursor->node, - &elm->leaf.base.delete_tid, - sizeof(elm->leaf.base.delete_tid)); + elm, sizeof(*elm)); elm->leaf.base.delete_tid = tid; + elm->leaf.delete_ts = cursor->trans->time32; hammer_modify_node_done(cursor->node); /* diff --git a/sys/vfs/hammer/hammer_prune.c b/sys/vfs/hammer/hammer_prune.c index fb5ccf8eeb..469e447e7d 100644 --- a/sys/vfs/hammer/hammer_prune.c +++ b/sys/vfs/hammer/hammer_prune.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_prune.c,v 1.6 2008/06/10 00:40:31 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_prune.c,v 1.7 2008/06/24 17:38:17 dillon Exp $ */ #include "hammer.h" @@ -65,19 +65,24 @@ hammer_ioc_prune(hammer_transaction_t trans, hammer_inode_t ip, if (prune->nelms < 0 || prune->nelms > HAMMER_MAX_PRUNE_ELMS) return(EINVAL); - if (prune->beg_localization > prune->end_localization) + if ((prune->key_beg.localization | prune->key_end.localization) & + HAMMER_LOCALIZE_PSEUDOFS_MASK) { return(EINVAL); - if (prune->beg_localization == prune->end_localization) { - if (prune->beg_obj_id > prune->end_obj_id) + } + if (prune->key_beg.localization > prune->key_end.localization) + return(EINVAL); + if (prune->key_beg.localization == prune->key_end.localization) { + if (prune->key_beg.obj_id > prune->key_end.obj_id) return(EINVAL); /* key-space limitations - no check needed */ } if ((prune->head.flags & HAMMER_IOC_PRUNE_ALL) && prune->nelms) return(EINVAL); - prune->cur_localization = prune->end_localization; - prune->cur_obj_id = prune->end_obj_id; - prune->cur_key = HAMMER_MAX_KEY; + prune->key_cur.localization = prune->key_end.localization + + ip->obj_localization; + prune->key_cur.obj_id = prune->key_end.obj_id; + prune->key_cur.key = HAMMER_MAX_KEY; /* * Copy element array from userland @@ -98,17 +103,18 @@ retry: hammer_done_cursor(&cursor); goto failed; } - cursor.key_beg.localization = prune->beg_localization; - cursor.key_beg.obj_id = prune->beg_obj_id; + cursor.key_beg.localization = prune->key_beg.localization + + ip->obj_localization; + cursor.key_beg.obj_id = prune->key_beg.obj_id; cursor.key_beg.key = HAMMER_MIN_KEY; cursor.key_beg.create_tid = 1; cursor.key_beg.delete_tid = 0; cursor.key_beg.rec_type = HAMMER_MIN_RECTYPE; cursor.key_beg.obj_type = 0; - cursor.key_end.localization = prune->cur_localization; - cursor.key_end.obj_id = prune->cur_obj_id; - cursor.key_end.key = prune->cur_key; + cursor.key_end.localization = prune->key_cur.localization; + cursor.key_end.obj_id = prune->key_cur.obj_id; + cursor.key_end.key = prune->key_cur.key; cursor.key_end.create_tid = HAMMER_MAX_TID - 1; cursor.key_end.delete_tid = 0; cursor.key_end.rec_type = HAMMER_MAX_RECTYPE; @@ -148,9 +154,7 @@ retry: * Check for work */ elm = &cursor.node->ondisk->elms[cursor.index]; - prune->cur_localization = elm->base.localization; - prune->cur_obj_id = elm->base.obj_id; - prune->cur_key = elm->base.key; + prune->key_cur = elm->base; if (prune->stat_oldest_tid > elm->leaf.base.create_tid) prune->stat_oldest_tid = elm->leaf.base.create_tid; @@ -227,6 +231,7 @@ retry: error = 0; } failed: + prune->key_cur.localization &= HAMMER_LOCALIZE_MASK; prune->elms = user_elms; kfree(copy_elms, M_TEMP); return(error); diff --git a/sys/vfs/hammer/hammer_reblock.c b/sys/vfs/hammer/hammer_reblock.c index 617bfdba86..a39dbb5fa9 100644 --- a/sys/vfs/hammer/hammer_reblock.c +++ b/sys/vfs/hammer/hammer_reblock.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_reblock.c,v 1.20 2008/06/21 20:21:58 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_reblock.c,v 1.21 2008/06/24 17:38:17 dillon Exp $ */ /* * HAMMER reblocker - This code frees up fragmented physical space @@ -63,30 +63,35 @@ hammer_ioc_reblock(hammer_transaction_t trans, hammer_inode_t ip, hammer_btree_elm_t elm; int error; - if (reblock->beg_obj_id >= reblock->end_obj_id) + if ((reblock->key_beg.localization | reblock->key_end.localization) & + HAMMER_LOCALIZE_PSEUDOFS_MASK) { + return(EINVAL); + } + if (reblock->key_beg.obj_id >= reblock->key_end.obj_id) return(EINVAL); if (reblock->free_level < 0) return(EINVAL); - reblock->cur_obj_id = reblock->beg_obj_id; - reblock->cur_localization = reblock->beg_localization; + reblock->key_cur = reblock->key_beg; + reblock->key_cur.localization += ip->obj_localization; retry: error = hammer_init_cursor(trans, &cursor, NULL, NULL); if (error) { hammer_done_cursor(&cursor); - return(error); + goto failed; } - cursor.key_beg.localization = reblock->cur_localization; - cursor.key_beg.obj_id = reblock->cur_obj_id; + cursor.key_beg.localization = reblock->key_cur.localization; + cursor.key_beg.obj_id = reblock->key_cur.obj_id; cursor.key_beg.key = HAMMER_MIN_KEY; cursor.key_beg.create_tid = 1; cursor.key_beg.delete_tid = 0; cursor.key_beg.rec_type = HAMMER_MIN_RECTYPE; cursor.key_beg.obj_type = 0; - cursor.key_end.localization = reblock->end_localization; - cursor.key_end.obj_id = reblock->end_obj_id; + cursor.key_end.localization = reblock->key_end.localization + + ip->obj_localization; + cursor.key_end.obj_id = reblock->key_end.obj_id; cursor.key_end.key = HAMMER_MAX_KEY; cursor.key_end.create_tid = HAMMER_MAX_TID - 1; cursor.key_end.delete_tid = 0; @@ -110,8 +115,8 @@ retry: * Internal or Leaf node */ elm = &cursor.node->ondisk->elms[cursor.index]; - reblock->cur_obj_id = elm->base.obj_id; - reblock->cur_localization = elm->base.localization; + reblock->key_cur.obj_id = elm->base.obj_id; + reblock->key_cur.localization = elm->base.localization; /* * Yield to more important tasks @@ -150,6 +155,8 @@ retry: reblock->head.flags |= HAMMER_IOC_HEAD_INTR; error = 0; } +failed: + reblock->key_cur.localization &= HAMMER_LOCALIZE_MASK; return(error); } diff --git a/sys/vfs/hammer/hammer_transaction.c b/sys/vfs/hammer/hammer_transaction.c index 5639da19ce..d0f1d1a0c9 100644 --- a/sys/vfs/hammer/hammer_transaction.c +++ b/sys/vfs/hammer/hammer_transaction.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_transaction.c,v 1.20 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_transaction.c,v 1.21 2008/06/24 17:38:17 dillon Exp $ */ #include "hammer.h" @@ -57,8 +57,8 @@ hammer_start_transaction(struct hammer_transaction *trans, trans->sync_lock_refs = 0; getmicrotime(&tv); - trans->time = (unsigned long)tv.tv_sec * 1000000ULL + - tv.tv_usec; + trans->time = (unsigned long)tv.tv_sec * 1000000ULL + tv.tv_usec; + trans->time32 = (u_int32_t)tv.tv_sec; } /* @@ -79,8 +79,8 @@ hammer_simple_transaction(struct hammer_transaction *trans, trans->sync_lock_refs = 0; getmicrotime(&tv); - trans->time = (unsigned long)tv.tv_sec * 1000000ULL + - tv.tv_usec; + trans->time = (unsigned long)tv.tv_sec * 1000000ULL + tv.tv_usec; + trans->time32 = (u_int32_t)tv.tv_sec; } /* @@ -108,8 +108,8 @@ hammer_start_transaction_fls(struct hammer_transaction *trans, trans->sync_lock_refs = 1; getmicrotime(&tv); - trans->time = (unsigned long)tv.tv_sec * 1000000ULL + - tv.tv_usec; + trans->time = (unsigned long)tv.tv_sec * 1000000ULL + tv.tv_usec; + trans->time32 = (u_int32_t)tv.tv_sec; } void diff --git a/sys/vfs/hammer/hammer_vfsops.c b/sys/vfs/hammer/hammer_vfsops.c index 470001aa86..de70dc65b9 100644 --- a/sys/vfs/hammer/hammer_vfsops.c +++ b/sys/vfs/hammer/hammer_vfsops.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/vfs/hammer/hammer_vfsops.c,v 1.52 2008/06/23 21:42:48 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_vfsops.c,v 1.53 2008/06/24 17:38:17 dillon Exp $ */ #include @@ -267,7 +267,7 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data, hmp->namekey_iterator = mycpu->gd_time_seconds; /*TAILQ_INIT(&hmp->recycle_list);*/ - hmp->root_btree_beg.localization = HAMMER_MIN_LOCALIZATION; + hmp->root_btree_beg.localization = 0x00000000U; hmp->root_btree_beg.obj_id = -0x8000000000000000LL; hmp->root_btree_beg.key = -0x8000000000000000LL; hmp->root_btree_beg.create_tid = 1; @@ -275,7 +275,7 @@ hammer_vfs_mount(struct mount *mp, char *mntpt, caddr_t data, hmp->root_btree_beg.rec_type = 0; hmp->root_btree_beg.obj_type = 0; - hmp->root_btree_end.localization = HAMMER_MAX_LOCALIZATION; + hmp->root_btree_end.localization = 0xFFFFFFFFU; hmp->root_btree_end.obj_id = 0x7FFFFFFFFFFFFFFFLL; hmp->root_btree_end.key = 0x7FFFFFFFFFFFFFFFLL; hmp->root_btree_end.create_tid = 0xFFFFFFFFFFFFFFFFULL; -- 2.41.0