Lines Matching refs:journal

66  * logging of trim-related calls within the journal.  (They're
75 SYSCTL_INT(_vfs_generic_jnl_kdebug, OID_AUTO, trim, CTLFLAG_RW|CTLFLAG_LOCKED, &jnl_kdebug, 0, "Enable kdebug logging for journal TRIM");
86 * Cap the journal max size to 2GB. On HFS, it will attempt to occupy
139 SYSCTL_UINT (_kern, OID_AUTO, jnl_trim_flush, CTLFLAG_RW, &jnl_trim_flush_limit, 0, "number of trimmed extents to cause a journal flush");
155 static void lock_condition(journal *jnl, boolean_t *condition, const char *condition_name);
156 static void wait_condition(journal *jnl, boolean_t *condition, const char *condition_name);
157 static void unlock_condition(journal *jnl, boolean_t *condition);
159 static void write_header_thread(journal *jnl);
162 static void abort_transaction(journal *jnl, transaction *tr);
163 static void dump_journal(journal *jnl);
165 static __inline__ void lock_oldstart(journal *jnl);
166 static __inline__ void unlock_oldstart(journal *jnl);
167 static __inline__ void lock_flush(journal *jnl);
168 static __inline__ void unlock_flush(journal *jnl);
172 // 3105942 - Coalesce writes to the same block on journal replay
184 static int add_block(journal *jnl, struct bucket **buf_ptr, off_t block_num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr);
187 static int do_overlap(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t block_num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr);
188 static int insert_block(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr, int overwriting);
193 panic("%s:%d: null journal ptr?\n", __FILE__, __LINE__); \
232 panic("%s:%d: tr journal start looks bad: 0x%llx\n", __FILE__, __LINE__, tr->journal_start); \
235 panic("%s:%d: tr journal end looks bad: 0x%llx\n", __FILE__, __LINE__, tr->journal_end); \
246 // we use it to checksum the journal header and the block list
279 journal_lock(journal *jnl)
289 journal_unlock(journal *jnl)
296 lock_flush(journal *jnl)
302 unlock_flush(journal *jnl)
308 lock_oldstart(journal *jnl)
314 unlock_oldstart(journal *jnl)
327 // journal device strategy routine (so that it won't get cached in
331 // outside the journal boundaries and it will wrap the i/o back
332 // to the beginning if necessary (skipping over the journal header)
335 do_journal_io(journal *jnl, off_t *offset, void *data, size_t len, int direction)
379 * here and issue directly to the disk device that the journal protects since we don't
439 read_journal_data(journal *jnl, off_t *offset, void *data, size_t len)
445 write_journal_data(journal *jnl, off_t *offset, void *data, size_t len)
452 read_journal_header(journal *jnl, void *data, size_t len)
460 write_journal_header(journal *jnl, int updating_start, uint32_t sequence_num)
502 printf("jnl: %s: write_journal_header: error writing the journal header!\n", jnl->jdev_name);
508 // have to flush after writing the journal header so that
511 // journal header refers to. Saw this exact case happen
529 // paging. it gets called by each of the journal api entry
533 free_old_stuff(journal *jnl)
572 journal *jnl;
654 // if we are here then we need to update the journal header
746 swap_journal_header(journal *jnl)
760 swap_block_list_header(journal *jnl, block_list_header *blhdr)
784 update_fs_block(journal *jnl, void *block_ptr, off_t fs_block, size_t bsize)
813 // copy the journal data over top of it
925 insert_block(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t num, size_t size, size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr, int overwriting)
966 do_overlap(journal *jnl, struct bucket **buf_ptr, int blk_index, off_t block_num, size_t size, __unused size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr)
1075 // PR-3105942: Coalesce writes to the same block in journal replay
1077 // to be replayed and the corresponding location in the journal which contains
1079 // blocks in the journal have been coalesced. The code for the case of conflicting/
1081 // disrupt the existing time-ordering of blocks in the journal playback, care
1084 add_block(journal *jnl, struct bucket **buf_ptr, off_t block_num, size_t size, __unused size_t offset, int32_t cksum, int *num_buckets_ptr, int *num_full_ptr)
1112 replay_journal(journal *jnl)
1126 // wrap the start ptr if it points to the very end of the journal
1211 // if there's nothing in the journal at all, just bail out altogether.
1255 printf("jnl: %s: replay_journal: bad looking journal entry: max: %d num: %d\n",
1287 //printf("jnl: replay_journal: adding %d blocks in journal entry @ 0x%llx to co_buf\n",
1311 printf("jnl: %s: replay_journal: Could not read journal entry data @ offset 0x%llx!\n", jnl->jdev_name, offset);
1365 printf("jnl: %s: no known good txn start offset! aborting journal replay.\n", jnl->jdev_name);
1369 /* Repeated error during journal replay, abort replay */
1371 printf("jnl: %s: repeated errors replaying journal! aborting journal replay.\n", jnl->jdev_name);
1376 /* There was an error replaying the journal (possibly
1385 printf("jnl: %s: restarting journal replay (%lld - %lld)!\n", jnl->jdev_name, jnl->jhdr->start, jnl->jhdr->end);
1391 // wrap around and skip the journal header block
1444 // do journal read, and set the phys. block
1447 printf("jnl: %s: replay_journal: Could not read journal entry data @ offset 0x%llx!\n", jnl->jdev_name, offset);
1463 printf("jnl: %s: journal replay done.\n", jnl->jdev_name);
1504 size_up_tbuffer(journal *jnl, int tbuffer_size, int phys_blksz)
1557 get_io_info(struct vnode *devvp, size_t phys_blksz, journal *jnl, struct vfs_context *context)
1639 journal *
1651 journal *jnl;
1657 * Cap the journal max size to 2GB. On HFS, it will attempt to occupy
1673 printf("jnl: %s: create: journal size %lld looks bogus.\n", jdev_name, journal_size);
1680 printf("jnl: %s: create: journal size (%lld) too small given sector size of (%u)\n",
1692 printf("jnl: %s: create: journal size 0x%llx is not an even multiple of block size 0x%ux\n",
1698 MALLOC_ZONE(jnl, struct journal *, sizeof(struct journal), M_JNL_JNL, M_WAITOK);
1731 // We try and read the journal header to see if there is already one
1741 // journal header and the sequence number is non-zero we write junk
1742 // over the entire journal so that there is no way we will encounter
1744 // since most tools erase the journal.
1765 printf("jnl: create: done clearing journal (i=%d)\n", i);
1783 // XXXdbg - for testing you can force the journal to wrap around
1802 printf("jnl: %s: journal_create: failed to write journal header.\n", jdev_name);
1813 FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
1823 journal *
1835 journal *jnl;
1858 printf("jnl: %s: open: journal size %lld looks bogus.\n", jdev_name, journal_size);
1865 printf("jnl: %s: open: journal size (%lld) too small given sector size of (%u)\n",
1871 printf("jnl: %s: open: journal size 0x%llx is not an even multiple of block size 0x%x\n",
1876 MALLOC_ZONE(jnl, struct journal *, sizeof(struct journal), M_JNL_JNL, M_WAITOK);
1909 printf("jnl: %s: open: could not read %u bytes for the journal header.\n",
1928 printf("jnl: %s: open: journal magic is bad (0x%x != 0x%x)\n",
1933 // only check if we're the current journal header magic value
1937 printf("jnl: %s: open: journal checksum is bad (0x%x != 0x%x)\n",
1956 * journal's header size. This will allow us to replay the journal
1957 * safely. If the replay succeeds, we will update the journal's header
1995 printf("jnl: %s: open: journal start (0x%llx) not a multiple of 512?\n",
2002 printf("jnl: %s: open: journal end (0x%llx) not a multiple of block size (0x%x)?\n",
2007 // take care of replaying the journal if necessary
2009 printf("jnl: %s: journal start/end pointers reset! (jnl %p; s 0x%llx e 0x%llx)\n",
2013 printf("jnl: %s: journal_open: Error replaying the journal!\n", jdev_name);
2018 * When we get here, we know that the journal is empty (jnl->jhdr->start ==
2020 * the journal's header size, then we can now restore the device's logical
2021 * block size and update the journal's header size to match.
2023 * Note that we also adjust the journal's start and end so that they will
2026 * journal header size. (See the comments in journal_create(), above.)
2043 printf("jnl: %s: open: failed to update journal header size\n", jdev_name);
2052 // set this now, after we've replayed the journal
2076 FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
2093 journal jnl;
2118 printf("jnl: %s: is_clean: journal size %lld looks bogus.\n", jdev_name, journal_size);
2124 printf("jnl: %s: is_clean: journal size 0x%llx is not an even multiple of block size 0x%x\n",
2152 printf("jnl: %s: is_clean: could not read %d bytes for the journal header.\n",
2172 printf("jnl: %s: is_clean: journal magic is bad (0x%x != 0x%x)\n",
2179 printf("jnl: %s: is_clean: journal checksum is bad (0x%x != 0x%x)\n", jdev_name, orig_checksum, checksum);
2185 // if the start and end are equal then the journal is clean.
2191 ret = EBUSY; // so the caller can differentiate an invalid journal from a "busy" one
2203 journal_close(journal *jnl)
2222 // only write stuff to disk if the journal is still valid
2267 // make sure this is in sync when we close the journal
2273 // if we're here the journal isn't valid any more.
2275 printf("jnl: %s: close: journal %p, is invalid. aborting outstanding transactions\n", jnl->jdev_name, jnl);
2311 FREE_ZONE(jnl, sizeof(struct journal), M_JNL_JNL);
2315 dump_journal(journal *jnl)
2319 printf("journal for dev %s:", jnl->jdev_name);
2338 free_space(journal *jnl)
2347 // journal is completely empty
2356 // The journal must be locked on entry to this function.
2360 check_free_space(journal *jnl, int desired_size, boolean_t *delayed_header_write, uint32_t sequence_num)
2374 // make sure there's space in the journal to hold this transaction
2461 // to complete and thus free up space in the journal.
2478 journal_allocate_transaction(journal *jnl)
2488 * due to waiting for the journal on the swap file creation path...
2507 // journal replay code checksum check depends on this.
2529 journal_start_transaction(journal *jnl)
2559 // make sure there's room in the journal
2601 journal_modify_block_start(journal *jnl, struct buf *bp)
2680 // make sure that this transaction isn't bigger than the whole journal
2709 journal_modify_block_abort(journal *jnl, struct buf *bp)
2776 journal_modify_block_end(journal *jnl, struct buf *bp, void (*func)(buf_t bp, void *arg), void *arg)
2852 // journal replay code checksum check depends on this.
2914 journal_kill_block(journal *jnl, struct buf *bp)
2992 ; Function: Provide the journal with a routine to be called back when a
2997 ; CAUTION: If the journal becomes invalid (eg., due to an I/O
2998 ; error when trying to write to the journal), this callback
3000 ; the journal became invalid!
3003 ; jnl - The journal structure for the filesystem.
3009 journal_trim_set_callback(journal *jnl, jnl_trim_callback_t callback, void *arg)
3040 trim_realloc(journal *jnl, struct jnl_trim_list *trim)
3055 * due to waiting for the journal on the swap file creation path...
3154 ; transaction has been written to the journal. (For example,
3164 ; written to the journal.)
3167 ; jnl - The journal for the volume containing the byte range.
3173 journal_trim_add_extent(journal *jnl, uint64_t offset, uint64_t length)
3293 int journal_trim_extent_overlap (journal *jnl, uint64_t offset, uint64_t length, uint64_t *end) {
3307 * pointer in the journal struct. This has a trimlist pointer which needs
3346 * FS requests that the journal flush immediately upon the
3353 journal_request_immediate_flush (journal *jnl) {
3380 ; Any overlapping ranges currently in the journal's trim list will
3383 ; is written to the journal.
3396 trim_remove_extent(journal *jnl, struct jnl_trim_list *trim, uint64_t offset, uint64_t length)
3517 ; jnl - The journal for the volume containing the byte range.
3523 journal_trim_remove_extent(journal *jnl, uint64_t offset, uint64_t length)
3590 journal_trim_flush(journal *jnl, transaction *tr)
3603 * due to waiting for the journal on the swap file creation path...
3628 * CAUTION: If the journal becomes invalid (eg., due to an I/O
3629 * error when trying to write to the journal), this callback
3631 * the journal became invalid!
3703 * written into the journal first, then the are written asynchronously. When
3705 * the journal.
3708 * the blocks have been written to the journal, but before the async writes
3710 * journal_relocate so that the location of the journal can be changed and
3713 * the journal during this end_transaction call; you probably want to set the
3717 * tr Transaction to add to the journal
3718 * force_it If true, force this transaction to the on-disk journal immediately.
3724 * -1 An error occurred. The journal is marked invalid.
3732 journal *jnl = tr->jnl;
3779 * that caused it to mark the journal invalid... if that
3810 * the journal lock since it will be bumped upon the start of the
3811 * next transaction group which may overlap the current journal flush...
3812 * we pass the snapshot into write_journal_header during the journal
3815 * of the journal flush, 'saved_sequence_num' remains stable
3822 * space for this transaction in the journal and jnl->old_start[0]
3841 * fire up a thread to write the journal header
3851 // this transaction starts where the current journal ends
3960 * if callback != NULL, we don't want to drop the journal
4014 write_header_thread(journal *jnl)
4035 journal *jnl = tr->jnl;
4061 * due to waiting for the journal on the swap file creation path...
4157 * before writing the actual journal data
4178 printf("jnl: %s: end_transaction: only wrote %d of %d bytes to the journal!\n",
4185 jnl->jhdr->end = end; // update where the journal now ends
4189 panic("jnl: end_transaction: bad tr journal start/end: 0x%llx 0x%llx\n",
4199 * written to the journal. This is used by journal_relocate so, for example,
4200 * the file system can change its pointer to the new journal.
4295 * before grabbing the journal lock... this avoids a deadlock
4296 * in 'end_transaction' which is holding the journal lock while
4320 lock_condition(journal *jnl, boolean_t *condition, const char *condition_name)
4337 wait_condition(journal *jnl, boolean_t *condition, const char *condition_name)
4356 unlock_condition(journal *jnl, boolean_t *condition)
4367 abort_transaction(journal *jnl, transaction *tr)
4417 * once the journal has been marked INVALID and aborted,
4477 journal_end_transaction(journal *jnl)
4505 panic("jnl: journal @ %p has active tr (%p) and cur tr (%p)\n",
4528 /* Examine the force-journal-flush state in the active txn */
4537 /* in the common path we can simply use the double-buffered journal */
4546 * Flush the contents of the journal to the disk.
4550 * If TRUE, wait to write in-memory journal to the disk
4553 * consistently on the disk. This means that the journal
4557 * to be consistent on-disk instead of just the journal
4561 * If FALSE, only wait to write in-memory journal to the
4562 * disk consistently. This means that the journal still
4564 * metadata blocks in the journal transactions might be
4569 * guarantees consistent journal content on the disk.
4572 journal_flush(journal *jnl, boolean_t wait_for_IO)
4614 /* Because of pipelined journal, the journal transactions
4617 * synchronize ourselves with the pipelined journal thread
4633 journal_active(journal *jnl)
4643 journal_owner(journal *jnl)
4648 int journal_uses_fua(journal *jnl)
4656 * Relocate the journal.
4658 * You provide the new starting offset and size for the journal. You may
4660 * changing the tbuffer size except as needed to fit within the new journal
4664 * modified blocks (such as those needed to deallocate the old journal,
4665 * allocate the new journal, and update the location and size of the journal
4667 * transaction will be flushed to the old journal. The new journal will be
4669 * the new journal.
4672 * and size of the journal. These updates should be made in the supplied
4675 * even of a crash, either the old journal will be found, with an empty journal,
4676 * or the new journal will be found with the contents of the active transaction.
4681 * (Remember that we have to ensure that blocks get committed to the journal
4683 * as committed until the new journal is pointed at.)
4688 * blocks will (eventually) go to the relocated journal.
4691 * jnl The (opened) journal to relocate.
4692 * offset The new journal byte offset (from start of the journal device).
4693 * journal_size The size, in bytes, of the new journal.
4695 * the same size as the current journal. The size will be
4696 * modified as needed to fit the new journal.
4697 * callback Routine called after the new journal has been initialized,
4698 * and the active transaction written to the new journal, but
4707 * EINVAL The journal is invalid
4711 int journal_relocate(journal *jnl, off_t offset, off_t journal_size, int32_t tbuffer_size,
4727 printf("jnl: %s: relocate: journal size 0x%llx is not an even multiple of block size 0x%x\n",
4765 * journal to disk (and have asynchronously written all of the txns to
4768 * started at the beginning of the journal (starting 1 block into the
4769 * journal file) it could confuse the buffer_flushed callback. This is
4770 * because we're about to reset the start/end pointers of the journal header
4779 /* Update the journal's offset and size in memory. */
4786 * Force the active transaction to be written to the new journal. Call the
4787 * supplied callback after the blocks have been written to the journal, but
4818 int journal_uses_fua(__unused journal *jnl)
4823 journal *
4838 journal *
4855 journal_modify_block_start(__unused journal *jnl, __unused struct buf *bp)
4861 journal_modify_block_end(__unused journal *jnl,
4870 journal_kill_block(__unused journal *jnl, __unused struct buf *bp)
4875 int journal_relocate(__unused journal *jnl,
4886 journal_close(__unused journal *jnl)
4891 journal_start_transaction(__unused journal *jnl)
4897 journal_end_transaction(__unused journal *jnl)
4903 journal_flush(__unused journal *jnl, __unused boolean_t wait_for_IO)
4920 journal_owner(__unused journal *jnl)
4926 journal_lock(__unused journal *jnl)
4932 journal_unlock(__unused journal *jnl)
4938 journal_trim_add_extent(__unused journal *jnl,
4946 journal_request_immediate_flush(__unused journal *jnl)
4952 journal_trim_remove_extent(__unused journal *jnl,
4959 int journal_trim_extent_overlap(__unused journal *jnl,