[BACK]Return to vfs_wapbl.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/vfs_wapbl.c between version 1.13 and 1.14

version 1.13, 2008/11/18 19:31:35 version 1.14, 2008/11/18 22:21:48
Line 201  static int wapbl_write_revocations(struc
Line 201  static int wapbl_write_revocations(struc
 static int wapbl_write_inodes(struct wapbl *wl, off_t *offp);  static int wapbl_write_inodes(struct wapbl *wl, off_t *offp);
 #endif /* _KERNEL */  #endif /* _KERNEL */
   
 static int wapbl_replay_process(struct wapbl_replay *wr);  static int wapbl_replay_process(struct wapbl_replay *wr, off_t, off_t);
   
 static __inline size_t wapbl_space_free(size_t avail, off_t head,  static __inline size_t wapbl_space_free(size_t avail, off_t head,
         off_t tail);          off_t tail);
Line 392  wapbl_start(struct wapbl ** wlp, struct 
Line 392  wapbl_start(struct wapbl ** wlp, struct 
         /* Initialize the commit header */          /* Initialize the commit header */
         {          {
                 struct wapbl_wc_header *wc;                  struct wapbl_wc_header *wc;
                 size_t len = 1<<wl->wl_log_dev_bshift;                  size_t len = 1 << wl->wl_log_dev_bshift;
                 wc = wapbl_calloc(1, len);                  wc = wapbl_calloc(1, len);
                 wc->wc_type = WAPBL_WC_HEADER;                  wc->wc_type = WAPBL_WC_HEADER;
                 wc->wc_len = len;                  wc->wc_len = len;
Line 424  wapbl_start(struct wapbl ** wlp, struct 
Line 424  wapbl_start(struct wapbl ** wlp, struct 
                 KDASSERT(!wapbl_replay_isopen(wr));                  KDASSERT(!wapbl_replay_isopen(wr));
                 KASSERT(devvp->v_rdev == wr->wr_devvp->v_rdev);                  KASSERT(devvp->v_rdev == wr->wr_devvp->v_rdev);
                 KASSERT(logpbn == wr->wr_logpbn);                  KASSERT(logpbn == wr->wr_logpbn);
                 KASSERT(wl->wl_circ_size == wr->wr_wc_header.wc_circ_size);                  KASSERT(wl->wl_circ_size == wr->wr_circ_size);
                 KASSERT(wl->wl_circ_off == wr->wr_wc_header.wc_circ_off);                  KASSERT(wl->wl_circ_off == wr->wr_circ_off);
                 KASSERT(wl->wl_log_dev_bshift ==                  KASSERT(wl->wl_log_dev_bshift == wr->wr_log_dev_bshift);
                     wr->wr_wc_header.wc_log_dev_bshift);                  KASSERT(wl->wl_fs_dev_bshift == wr->wr_fs_dev_bshift);
                 KASSERT(wl->wl_fs_dev_bshift ==  
                     wr->wr_wc_header.wc_fs_dev_bshift);  
   
                 wl->wl_wc_header->wc_generation =                  wl->wl_wc_header->wc_generation = wr->wr_generation + 1;
                     wr->wr_wc_header.wc_generation + 1;  
   
                 for (i = 0; i < wr->wr_inodescnt; i++)                  for (i = 0; i < wr->wr_inodescnt; i++)
                         wapbl_register_inode(wl, wr->wr_inodes[i].wr_inumber,                          wapbl_register_inode(wl, wr->wr_inodes[i].wr_inumber,
Line 2049  wapbl_write_inodes(struct wapbl *wl, off
Line 2046  wapbl_write_inodes(struct wapbl *wl, off
         struct wapbl_wc_inodelist *wc =          struct wapbl_wc_inodelist *wc =
             (struct wapbl_wc_inodelist *)wl->wl_wc_scratch;              (struct wapbl_wc_inodelist *)wl->wl_wc_scratch;
         int i;          int i;
         int blocklen = 1<<wl->wl_log_dev_bshift;          int blocklen = 1 << wl->wl_log_dev_bshift;
         off_t off = *offp;          off_t off = *offp;
         int error;          int error;
   
Line 2227  static int
Line 2224  static int
 wapbl_circ_read(struct wapbl_replay *wr, void *data, size_t len, off_t *offp)  wapbl_circ_read(struct wapbl_replay *wr, void *data, size_t len, off_t *offp)
 {  {
         size_t slen;          size_t slen;
         struct wapbl_wc_header *wc = &wr->wr_wc_header;  
         off_t off = *offp;          off_t off = *offp;
         int error;          int error;
   
         KASSERT(((len >> wc->wc_log_dev_bshift) <<          KASSERT(((len >> wr->wr_log_dev_bshift) <<
             wc->wc_log_dev_bshift) == len);              wr->wr_log_dev_bshift) == len);
         if (off < wc->wc_circ_off)          if (off < wr->wr_circ_off)
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         slen = wc->wc_circ_off + wc->wc_circ_size - off;          slen = wr->wr_circ_off + wr->wr_circ_size - off;
         if (slen < len) {          if (slen < len) {
                 error = wapbl_read(data, slen, wr->wr_devvp,                  error = wapbl_read(data, slen, wr->wr_devvp,
                     wr->wr_logpbn + (off >> wc->wc_log_dev_bshift));                      wr->wr_logpbn + (off >> wr->wr_log_dev_bshift));
                 if (error)                  if (error)
                         return error;                          return error;
                 data = (uint8_t *)data + slen;                  data = (uint8_t *)data + slen;
                 len -= slen;                  len -= slen;
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         }          }
         error = wapbl_read(data, len, wr->wr_devvp,          error = wapbl_read(data, len, wr->wr_devvp,
             wr->wr_logpbn + (off >> wc->wc_log_dev_bshift));              wr->wr_logpbn + (off >> wr->wr_log_dev_bshift));
         if (error)          if (error)
                 return error;                  return error;
         off += len;          off += len;
         if (off >= wc->wc_circ_off + wc->wc_circ_size)          if (off >= wr->wr_circ_off + wr->wr_circ_size)
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         *offp = off;          *offp = off;
         return 0;          return 0;
 }  }
Line 2260  static void
Line 2256  static void
 wapbl_circ_advance(struct wapbl_replay *wr, size_t len, off_t *offp)  wapbl_circ_advance(struct wapbl_replay *wr, size_t len, off_t *offp)
 {  {
         size_t slen;          size_t slen;
         struct wapbl_wc_header *wc = &wr->wr_wc_header;  
         off_t off = *offp;          off_t off = *offp;
   
         KASSERT(((len >> wc->wc_log_dev_bshift) <<          KASSERT(((len >> wr->wr_log_dev_bshift) <<
             wc->wc_log_dev_bshift) == len);              wr->wr_log_dev_bshift) == len);
   
         if (off < wc->wc_circ_off)          if (off < wr->wr_circ_off)
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         slen = wc->wc_circ_off + wc->wc_circ_size - off;          slen = wr->wr_circ_off + wr->wr_circ_size - off;
         if (slen < len) {          if (slen < len) {
                 len -= slen;                  len -= slen;
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         }          }
         off += len;          off += len;
         if (off >= wc->wc_circ_off + wc->wc_circ_size)          if (off >= wr->wr_circ_off + wr->wr_circ_size)
                 off = wc->wc_circ_off;                  off = wr->wr_circ_off;
         *offp = off;          *offp = off;
 }  }
   
Line 2352  wapbl_replay_start(struct wapbl_replay *
Line 2347  wapbl_replay_start(struct wapbl_replay *
   
         wr->wr_scratch = scratch;          wr->wr_scratch = scratch;
   
         memcpy(&wr->wr_wc_header, wch, sizeof(wr->wr_wc_header));          wr->wr_log_dev_bshift = wch->wc_log_dev_bshift;
           wr->wr_fs_dev_bshift = wch->wc_fs_dev_bshift;
           wr->wr_circ_off = wch->wc_circ_off;
           wr->wr_circ_size = wch->wc_circ_size;
           wr->wr_generation = wch->wc_generation;
   
         used = wapbl_space_used(wch->wc_circ_size, wch->wc_head, wch->wc_tail);          used = wapbl_space_used(wch->wc_circ_size, wch->wc_head, wch->wc_tail);
   
Line 2364  wapbl_replay_start(struct wapbl_replay *
Line 2363  wapbl_replay_start(struct wapbl_replay *
   
         wapbl_blkhash_init(wr, (used >> wch->wc_fs_dev_bshift));          wapbl_blkhash_init(wr, (used >> wch->wc_fs_dev_bshift));
   
         error = wapbl_replay_process(wr);          error = wapbl_replay_process(wr, wch->wc_head, wch->wc_tail);
         if (error) {          if (error) {
                 wapbl_replay_stop(wr);                  wapbl_replay_stop(wr);
                 wapbl_replay_free(wr);                  wapbl_replay_free(wr);
Line 2420  wapbl_replay_isopen1(struct wapbl_replay
Line 2419  wapbl_replay_isopen1(struct wapbl_replay
 static void  static void
 wapbl_replay_process_blocks(struct wapbl_replay *wr, off_t *offp)  wapbl_replay_process_blocks(struct wapbl_replay *wr, off_t *offp)
 {  {
         struct wapbl_wc_header *wch = &wr->wr_wc_header;  
         struct wapbl_wc_blocklist *wc =          struct wapbl_wc_blocklist *wc =
             (struct wapbl_wc_blocklist *)wr->wr_scratch;              (struct wapbl_wc_blocklist *)wr->wr_scratch;
         int fsblklen = 1<<wch->wc_fs_dev_bshift;          int fsblklen = 1 << wr->wr_fs_dev_bshift;
         int i, j, n;          int i, j, n;
   
         for (i = 0; i < wc->wc_blkcount; i++) {          for (i = 0; i < wc->wc_blkcount; i++) {
                 /*                  /*
                  * Enter each physical block into the hashtable independently.                   * Enter each physical block into the hashtable independently.
                  */                   */
                 n = wc->wc_blocks[i].wc_dlen >> wch->wc_fs_dev_bshift;                  n = wc->wc_blocks[i].wc_dlen >> wr->wr_fs_dev_bshift;
                 for (j = 0; j < n; j++) {                  for (j = 0; j < n; j++) {
                         wapbl_blkhash_ins(wr, wc->wc_blocks[i].wc_daddr + j,                          wapbl_blkhash_ins(wr, wc->wc_blocks[i].wc_daddr + j,
                             *offp);                              *offp);
Line 2442  wapbl_replay_process_blocks(struct wapbl
Line 2440  wapbl_replay_process_blocks(struct wapbl
 static void  static void
 wapbl_replay_process_revocations(struct wapbl_replay *wr)  wapbl_replay_process_revocations(struct wapbl_replay *wr)
 {  {
         struct wapbl_wc_header *wch = &wr->wr_wc_header;  
         struct wapbl_wc_blocklist *wc =          struct wapbl_wc_blocklist *wc =
             (struct wapbl_wc_blocklist *)wr->wr_scratch;              (struct wapbl_wc_blocklist *)wr->wr_scratch;
         int i, j, n;          int i, j, n;
Line 2451  wapbl_replay_process_revocations(struct 
Line 2448  wapbl_replay_process_revocations(struct 
                 /*                  /*
                  * Remove any blocks found from the hashtable.                   * Remove any blocks found from the hashtable.
                  */                   */
                 n = wc->wc_blocks[i].wc_dlen >> wch->wc_fs_dev_bshift;                  n = wc->wc_blocks[i].wc_dlen >> wr->wr_fs_dev_bshift;
                 for (j = 0; j < n; j++)                  for (j = 0; j < n; j++)
                         wapbl_blkhash_rem(wr, wc->wc_blocks[i].wc_daddr + j);                          wapbl_blkhash_rem(wr, wc->wc_blocks[i].wc_daddr + j);
         }          }
Line 2486  wapbl_replay_process_inodes(struct wapbl
Line 2483  wapbl_replay_process_inodes(struct wapbl
 }  }
   
 static int  static int
 wapbl_replay_process(struct wapbl_replay *wr)  wapbl_replay_process(struct wapbl_replay *wr, off_t head, off_t tail)
 {  {
         off_t off;          off_t off;
         struct wapbl_wc_header *wch = &wr->wr_wc_header;  
         int error;          int error;
   
         int logblklen = 1<<wch->wc_log_dev_bshift;          int logblklen = 1 << wr->wr_log_dev_bshift;
   
         wapbl_blkhash_clear(wr);          wapbl_blkhash_clear(wr);
   
         off = wch->wc_tail;          off = tail;
         while (off != wch->wc_head) {          while (off != head) {
                 struct wapbl_wc_null *wcn;                  struct wapbl_wc_null *wcn;
                 off_t saveoff = off;                  off_t saveoff = off;
                 error = wapbl_circ_read(wr, wr->wr_scratch, logblklen, &off);                  error = wapbl_circ_read(wr, wr->wr_scratch, logblklen, &off);
Line 2542  int
Line 2538  int
 wapbl_replay_verify(struct wapbl_replay *wr, struct vnode *fsdevvp)  wapbl_replay_verify(struct wapbl_replay *wr, struct vnode *fsdevvp)
 {  {
         off_t off;          off_t off;
         struct wapbl_wc_header *wch = &wr->wr_wc_header;  
         int mismatchcnt = 0;          int mismatchcnt = 0;
         int logblklen = 1<<wch->wc_log_dev_bshift;          int logblklen = 1 << wr->wr_log_dev_bshift;
         int fsblklen = 1<<wch->wc_fs_dev_bshift;          int fsblklen = 1 << wr->wr_fs_dev_bshift;
         void *scratch1 = wapbl_malloc(MAXBSIZE);          void *scratch1 = wapbl_malloc(MAXBSIZE);
         void *scratch2 = wapbl_malloc(MAXBSIZE);          void *scratch2 = wapbl_malloc(MAXBSIZE);
         int error = 0;          int error = 0;
Line 2661  wapbl_replay_verify(struct wapbl_replay 
Line 2656  wapbl_replay_verify(struct wapbl_replay 
 int  int
 wapbl_replay_write(struct wapbl_replay *wr, struct vnode *fsdevvp)  wapbl_replay_write(struct wapbl_replay *wr, struct vnode *fsdevvp)
 {  {
         struct wapbl_wc_header *wch = &wr->wr_wc_header;  
         struct wapbl_blk *wb;          struct wapbl_blk *wb;
         size_t i;          size_t i;
         off_t off;          off_t off;
         void *scratch;          void *scratch;
         int error = 0;          int error = 0;
         int fsblklen = 1 << wch->wc_fs_dev_bshift;          int fsblklen = 1 << wr->wr_fs_dev_bshift;
   
         KDASSERT(wapbl_replay_isopen(wr));          KDASSERT(wapbl_replay_isopen(wr));
   
Line 2693  wapbl_replay_write(struct wapbl_replay *
Line 2687  wapbl_replay_write(struct wapbl_replay *
 int  int
 wapbl_replay_can_read(struct wapbl_replay *wr, daddr_t blk, long len)  wapbl_replay_can_read(struct wapbl_replay *wr, daddr_t blk, long len)
 {  {
         struct wapbl_wc_header *wch = &wr->wr_wc_header;          int fsblklen = 1 << wr->wr_fs_dev_bshift;
         int fsblklen = 1<<wch->wc_fs_dev_bshift;  
   
         KDASSERT(wapbl_replay_isopen(wr));          KDASSERT(wapbl_replay_isopen(wr));
         KASSERT((len % fsblklen) == 0);          KASSERT((len % fsblklen) == 0);
Line 2711  wapbl_replay_can_read(struct wapbl_repla
Line 2704  wapbl_replay_can_read(struct wapbl_repla
 int  int
 wapbl_replay_read(struct wapbl_replay *wr, void *data, daddr_t blk, long len)  wapbl_replay_read(struct wapbl_replay *wr, void *data, daddr_t blk, long len)
 {  {
         struct wapbl_wc_header *wch = &wr->wr_wc_header;          int fsblklen = 1 << wr->wr_fs_dev_bshift;
         int fsblklen = 1<<wch->wc_fs_dev_bshift;  
   
         KDASSERT(wapbl_replay_isopen(wr));          KDASSERT(wapbl_replay_isopen(wr));
   

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

CVSweb <webmaster@jp.NetBSD.org>