From 5cc5e3bd2357e4740b66b80896eed2dc3077b185 Mon Sep 17 00:00:00 2001 From: dholland Date: Sat, 10 Oct 2015 22:33:31 +0000 Subject: [PATCH] Use accessors for some more indirect block manipulations. --- sys/ufs/lfs/lfs_balloc.c | 17 +++++++---------- sys/ufs/lfs/lfs_segment.c | 17 ++++++++--------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/sys/ufs/lfs/lfs_balloc.c b/sys/ufs/lfs/lfs_balloc.c index e4a3a64f3db8..04b908626e3f 100644 --- a/sys/ufs/lfs/lfs_balloc.c +++ b/sys/ufs/lfs/lfs_balloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_balloc.c,v 1.87 2015/09/01 06:08:37 dholland Exp $ */ +/* $NetBSD: lfs_balloc.c,v 1.88 2015/10/10 22:33:31 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.87 2015/09/01 06:08:37 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_balloc.c,v 1.88 2015/10/10 22:33:31 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -271,12 +271,10 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred, * If that is the case mark it UNWRITTEN to keep * the accounting straight. */ - /* XXX ondisk32 */ - if (((int32_t *)ibp->b_data)[indirs[i].in_off] == 0) - ((int32_t *)ibp->b_data)[indirs[i].in_off] = - UNWRITTEN; - /* XXX ondisk32 */ - idaddr = ((int32_t *)ibp->b_data)[indirs[i].in_off]; + if (lfs_iblock_get(fs, ibp->b_data, indirs[i].in_off) == 0) + lfs_iblock_set(fs, ibp->b_data, indirs[i].in_off, + UNWRITTEN); + idaddr = lfs_iblock_get(fs, ibp->b_data, indirs[i].in_off); #ifdef DEBUG if (vp == fs->lfs_ivnode) { LFS_ENTER_LOG("balloc", __FILE__, @@ -333,8 +331,7 @@ lfs_balloc(struct vnode *vp, off_t startoffset, int iosize, kauth_cred_t cred, B_MODIFY, &ibp)) panic("lfs_balloc: bread bno %lld", (long long)idp->in_lbn); - /* XXX ondisk32 */ - ((int32_t *)ibp->b_data)[idp->in_off] = UNWRITTEN; + lfs_iblock_set(fs, ibp->b_data, idp->in_off, UNWRITTEN); #ifdef DEBUG if (vp == fs->lfs_ivnode) { LFS_ENTER_LOG("balloc", __FILE__, diff --git a/sys/ufs/lfs/lfs_segment.c b/sys/ufs/lfs/lfs_segment.c index a8ada66c1e87..b2cc4dbd6891 100644 --- a/sys/ufs/lfs/lfs_segment.c +++ b/sys/ufs/lfs/lfs_segment.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_segment.c,v 1.260 2015/10/03 08:28:16 dholland Exp $ */ +/* $NetBSD: lfs_segment.c,v 1.261 2015/10/10 22:33:31 dholland Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.260 2015/10/03 08:28:16 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_segment.c,v 1.261 2015/10/10 22:33:31 dholland Exp $"); #ifdef DEBUG # define vndebug(vp, str) do { \ @@ -2035,7 +2035,7 @@ lfs_writeseg(struct lfs *fs, struct segment *sp) struct vnode *devvp; char *p = NULL; struct vnode *vp; - int32_t *daddrp; /* XXX ondisk32 */ + unsigned ibindex, iblimit; int changed; u_int32_t sum; size_t sumstart; @@ -2162,13 +2162,12 @@ lfs_writeseg(struct lfs *fs, struct segment *sp) newbp->b_bcount); changed = 0; - /* XXX ondisk32 */ - for (daddrp = (int32_t *)(newbp->b_data); - daddrp < (int32_t *)((char *)newbp->b_data + - newbp->b_bcount); daddrp++) { - if (*daddrp == UNWRITTEN) { + iblimit = newbp->b_bcount / LFS_BLKPTRSIZE(fs); + for (ibindex = 0; ibindex < iblimit; ibindex++) { + if (lfs_iblock_get(fs, newbp->b_data, ibindex) == UNWRITTEN) { ++changed; - *daddrp = 0; + lfs_iblock_set(fs, newbp->b_data, + ibindex, 0); } } /*