From owner-freebsd-fs@FreeBSD.ORG Wed Jan 14 03:35:56 2004 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8A5C016A4CE; Wed, 14 Jan 2004 03:35:56 -0800 (PST) Received: from mtaw6.prodigy.net (mtaw6.prodigy.net [64.164.98.56]) by mx1.FreeBSD.org (Postfix) with ESMTP id 617E543D49; Wed, 14 Jan 2004 03:35:54 -0800 (PST) (envelope-from zgh@malfunktion.net) Received: from balrog.thehouse (adsl-68-122-41-113.dsl.pltn13.pacbell.net [68.122.41.113]) by mtaw6.prodigy.net (8.12.10/8.12.10) with ESMTP id i0EBZ7FA019638; Wed, 14 Jan 2004 03:35:08 -0800 (PST) Received: from [10.0.0.6] (cyclops.thehouse [10.0.0.6]) by balrog.thehouse (Postfix) with ESMTP id 5A6DC33DF; Wed, 14 Jan 2004 03:35:47 -0800 (PST) From: Zack Hobson To: fs@freebsd.org Content-Type: multipart/mixed; boundary="=-13Mkz5Thyt8H3u1dvEWX" Message-Id: <1074080151.733.51.camel@cyclops.thehouse> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 Date: Wed, 14 Jan 2004 03:35:51 -0800 cc: yar@freebsd.org Subject: updating HFS for 5.2R [patch] X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2004 11:35:56 -0000 --=-13Mkz5Thyt8H3u1dvEWX Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi all, I'm interested in getting the recently-ported HFS code (thanks Yar!) working in 5.2-RELEASE. I downloaded version 03 of Yar's HFS code and was disappointed to learn that it no longer compiles on FreeBSD 5.2. After some digging through a source cross-reference service, I managed to figure out some of the API changes (I think), and found workarounds for the rest, enough to get it to compile at least. So far what I've done is this, I hope current fs hackers understand what I'm talking about, because I don't. ^_^ * the B_LOCKED flag is no longer supported, but I don't know enough about the fs code to figure out what to replace it with. I simply defined B_LOCKED with the original value, as a workaround. * I replaced calls to mtx_lock/mtx_unlock on the mntvnode_mtx global to MNT_ILOCK/MNT_IUNLOCK calls on the local mount point mutex (mp or mountp in the code). * There was at least one call to vrecycle that used the obsolete global mntvnode_mtx, by looking at code elsewhere I guessed that it's okay (correct?) to pass NULL instead. With these changes, the code compiles. I can install and load the resulting kernel module, and I can sucessfully use newfs_hfs and fsck_hfs, but mount_hfs on the same volume always fails with an "Input/output error". I've enclosed a patch that includes the changes I described above, it's based on the hfs-freebsd-03 source distribution: http://people.freebsd.org/~yar/hfs/ I hope that someone with experience in these matters might be willing to help. I'm an adequate C programmer, and I'm highly motivated to help with this, but my knowledge of the FreeBSD kernel and vfs are nil. I've already bugged Yar briefly and he's too busy with school to hack on this at the moment. Thanks and regards, -zack --=-13Mkz5Thyt8H3u1dvEWX Content-Disposition: inline; filename=hfs-freebsd-03_52R.diff Content-Type: text/x-patch; name=hfs-freebsd-03_52R.diff; charset= Content-Transfer-Encoding: 7bit diff -u -r ../hfs-freebsd-03/darwin/xnu/bsd/hfs/hfs.h darwin/xnu/bsd/hfs/hfs.h --- ../hfs-freebsd-03/darwin/xnu/bsd/hfs/hfs.h Sat Jun 21 06:33:42 2003 +++ darwin/xnu/bsd/hfs/hfs.h Wed Jan 14 01:39:11 2004 @@ -510,6 +510,9 @@ extern int hfs_namecmp(const char *, size_t, const char *, size_t); +#ifndef B_LOCKED +#define B_LOCKED 0x00004000 +#endif #endif /* __APPLE_API_PRIVATE */ #endif /* _KERNEL */ diff -u -r ../hfs-freebsd-03/darwin/xnu/bsd/hfs/hfs_vfsops.c darwin/xnu/bsd/hfs/hfs_vfsops.c --- ../hfs-freebsd-03/darwin/xnu/bsd/hfs/hfs_vfsops.c Tue Aug 12 07:43:56 2003 +++ darwin/xnu/bsd/hfs/hfs_vfsops.c Wed Jan 14 03:03:09 2004 @@ -495,7 +495,7 @@ * Note that we can visit a vnode more than once * and we can race with fsync. */ - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); loop: for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) { /* @@ -513,10 +513,10 @@ continue; } #endif - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mp); retval = vget(vp, LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK, p); if (retval) { - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); if (retval == ENOENT) goto loop; continue; @@ -524,7 +524,7 @@ #ifndef DARWIN /* access to v_vflag requires holding the vnode lock */ if (vp->v_vflag & VV_SYSTEM) { vput(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); continue; } #endif @@ -537,7 +537,7 @@ if (namefix) cache_purge(vp); vput(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); continue; } @@ -564,10 +564,10 @@ cat_releasedesc(&cndesc); } vput(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); } /* end for (vp...) */ - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mp); /* * If we're switching name converters we can now * connect the new hfs_get_hfsname converter and @@ -635,10 +635,10 @@ InvalidateCatalogCache(vcb); loop: - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mountp); for (vp = TAILQ_FIRST(&mountp->mnt_nvnodelist); vp != NULL; vp = nvp) { if (vp->v_mount != mountp) { - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mountp); goto loop; } nvp = TAILQ_NEXT(vp, v_nmntvnodes); @@ -646,13 +646,13 @@ /* * Invalidate all inactive vnodes. */ - if (vrecycle(vp, &mntvnode_mtx, p)) + if (vrecycle(vp, NULL, p)) goto loop; /* * Invalidate all cached file data. */ - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mountp); VI_LOCK(vp); if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, p)) { goto loop; @@ -681,9 +681,9 @@ (void) replace_desc(cp, &desc); } vput(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mountp); } - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mountp); /* * Re-read VolumeHeader from disk. @@ -1737,7 +1737,7 @@ */ loop: - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); for (vp = TAILQ_FIRST(&mp->mnt_nvnodelist); vp != NULL; vp = nvp) { #ifdef DARWIN_UBC int didhold; @@ -1747,12 +1747,12 @@ * associated with this mount point, start over. */ if (vp->v_mount != mp) { - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mp); goto loop; } nvp = TAILQ_NEXT(vp, v_nmntvnodes); - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mp); VI_LOCK(vp); cp = VTOC(vp); @@ -1761,7 +1761,7 @@ // or being reclaimed. if (cp == NULL) { VI_UNLOCK(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); continue; } @@ -1769,7 +1769,7 @@ (((cp->c_flag & (C_ACCESS | C_CHANGE | C_MODIFIED | C_UPDATE)) == 0) && TAILQ_EMPTY(&vp->v_dirtyblkhd))) { VI_UNLOCK(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); continue; } @@ -1777,7 +1777,7 @@ if (error) { if (error == ENOENT) goto loop; - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); continue; } @@ -1793,7 +1793,7 @@ ubc_rele(vp); #endif vrele(vp); - mtx_lock(&mntvnode_mtx); + MNT_ILOCK(mp); }; vcb = HFSTOVCB(hfsmp); @@ -1801,7 +1801,7 @@ meta_vp[0] = vcb->extentsRefNum; meta_vp[1] = vcb->catalogRefNum; meta_vp[2] = vcb->allocationsRefNum; /* This is NULL for standard HFS */ - mtx_unlock(&mntvnode_mtx); + MNT_IUNLOCK(mp); /* Now sync our three metadata files */ for (i = 0; i < 3; ++i) { --=-13Mkz5Thyt8H3u1dvEWX--