Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Extended attribute support for ffsv2, from FreeBSD.
details: https://anonhg.NetBSD.org/src/rev/f19fe4bf6f0e
branches: trunk
changeset: 1009261:f19fe4bf6f0e
user: christos <christos%NetBSD.org@localhost>
date: Sat Apr 18 19:18:33 2020 +0000
description:
Extended attribute support for ffsv2, from FreeBSD.
diffstat:
sys/modules/ffs/Makefile | 4 +-
sys/rump/fs/lib/libffs/Makefile | 4 +-
sys/ufs/ffs/ffs_alloc.c | 30 +-
sys/ufs/ffs/ffs_balloc.c | 60 +-
sys/ufs/ffs/ffs_extattr.c | 996 ++++++++++++++++++++++++++++++++++++++++
sys/ufs/ffs/ffs_extern.h | 27 +-
sys/ufs/ffs/ffs_inode.c | 66 +-
sys/ufs/ffs/ffs_snapshot.c | 22 +-
sys/ufs/ffs/ffs_vnops.c | 161 +------
sys/ufs/ffs/fs.h | 10 +-
sys/ufs/files.ufs | 3 +-
sys/ufs/ufs/extattr.h | 35 +-
sys/ufs/ufs/inode.h | 22 +-
sys/ufs/ufs/ufs_extern.h | 5 +-
sys/ufs/ufs/ufs_inode.c | 31 +-
sys/ufs/ufs/ufs_vnops.c | 6 +-
16 files changed, 1214 insertions(+), 268 deletions(-)
diffs (truncated from 1971 to 300 lines):
diff -r ebb3884e3ac1 -r f19fe4bf6f0e sys/modules/ffs/Makefile
--- a/sys/modules/ffs/Makefile Sat Apr 18 18:55:20 2020 +0000
+++ b/sys/modules/ffs/Makefile Sat Apr 18 19:18:33 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2019/08/19 09:31:30 christos Exp $
+# $NetBSD: Makefile,v 1.14 2020/04/18 19:18:33 christos Exp $
.include "../Makefile.inc"
@@ -11,7 +11,7 @@
CWARNFLAGS.clang= -Wno-conversion
SRCS+= ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_subr.c ffs_tables.c \
- ffs_vfsops.c ffs_vnops.c ffs_snapshot.c \
+ ffs_vfsops.c ffs_vnops.c ffs_snapshot.c ffs_extattr.c \
ffs_bswap.c ffs_wapbl.c ffs_appleufs.c ffs_quota2.c
WARNS= 3
diff -r ebb3884e3ac1 -r f19fe4bf6f0e sys/rump/fs/lib/libffs/Makefile
--- a/sys/rump/fs/lib/libffs/Makefile Sat Apr 18 18:55:20 2020 +0000
+++ b/sys/rump/fs/lib/libffs/Makefile Sat Apr 18 19:18:33 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2020/04/12 00:04:45 christos Exp $
+# $NetBSD: Makefile,v 1.18 2020/04/18 19:18:33 christos Exp $
#
.PATH: ${.CURDIR}/../../../../ufs/ffs ${.CURDIR}/../../../../ufs/ufs
@@ -8,7 +8,7 @@
SRCS= ffs_alloc.c ffs_appleufs.c ffs_balloc.c ffs_bswap.c ffs_inode.c \
ffs_snapshot.c ffs_subr.c ffs_tables.c ffs_vfsops.c ffs_vnops.c \
- ffs_wapbl.c ffs_quota2.c
+ ffs_wapbl.c ffs_quota2.c ffs_extattr.c
SRCS+= ufs_bmap.c ufs_dirhash.c ufs_extattr.c ufs_inode.c \
ufs_lookup.c ufs_rename.c ufs_vfsops.c ufs_vnops.c \
diff -r ebb3884e3ac1 -r f19fe4bf6f0e sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c Sat Apr 18 18:55:20 2020 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c Sat Apr 18 19:18:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_alloc.c,v 1.166 2020/02/23 15:46:42 ad Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.166 2020/02/23 15:46:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.167 2020/04/18 19:18:34 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -257,7 +257,10 @@
bno = ffs_hashalloc(ip, cg, bpref, size, 0, flags, ffs_alloccg);
if (bno > 0) {
DIP_ADD(ip, blocks, btodb(size));
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
+ if (flags & IO_EXT)
+ ip->i_flag |= IN_CHANGE;
+ else
+ ip->i_flag |= IN_CHANGE | IN_UPDATE;
*bnp = bno;
return (0);
}
@@ -300,14 +303,15 @@
* => return with um_lock released
*/
int
-ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bpref, int osize,
- int nsize, kauth_cred_t cred, struct buf **bpp, daddr_t *blknop)
+ffs_realloccg(struct inode *ip, daddr_t lbprev, daddr_t bprev, daddr_t bpref,
+ int osize, int nsize, int flags, kauth_cred_t cred, struct buf **bpp,
+ daddr_t *blknop)
{
struct ufsmount *ump;
struct fs *fs;
struct buf *bp;
int cg, request, error;
- daddr_t bprev, bno;
+ daddr_t bno;
fs = ip->i_fs;
ump = ip->i_ump;
@@ -368,10 +372,6 @@
mutex_exit(&ump->um_lock);
goto nospace;
}
- if (fs->fs_magic == FS_UFS2_MAGIC)
- bprev = ufs_rw64(ip->i_ffs2_db[lbprev], UFS_FSNEEDSWAP(fs));
- else
- bprev = ufs_rw32(ip->i_ffs1_db[lbprev], UFS_FSNEEDSWAP(fs));
if (bprev == 0) {
panic("%s: bad bprev: dev = 0x%llx, bsize = %d, bprev = %"
@@ -403,7 +403,10 @@
mutex_enter(&ump->um_lock);
if ((bno = ffs_fragextend(ip, cg, bprev, osize, nsize)) != 0) {
DIP_ADD(ip, blocks, btodb(nsize - osize));
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
+ if (flags & IO_EXT)
+ ip->i_flag |= IN_CHANGE;
+ else
+ ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
if (bp->b_blkno != FFS_FSBTODB(fs, bno)) {
@@ -503,7 +506,10 @@
ip->i_number);
}
DIP_ADD(ip, blocks, btodb(nsize - osize));
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
+ if (flags & IO_EXT)
+ ip->i_flag |= IN_CHANGE;
+ else
+ ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (bpp != NULL) {
bp->b_blkno = FFS_FSBTODB(fs, bno);
allocbuf(bp, nsize, 1);
diff -r ebb3884e3ac1 -r f19fe4bf6f0e sys/ufs/ffs/ffs_balloc.c
--- a/sys/ufs/ffs/ffs_balloc.c Sat Apr 18 18:55:20 2020 +0000
+++ b/sys/ufs/ffs/ffs_balloc.c Sat Apr 18 19:18:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_balloc.c,v 1.63 2017/10/28 00:37:13 pgoyette Exp $ */
+/* $NetBSD: ffs_balloc.c,v 1.64 2020/04/18 19:18:34 christos Exp $ */
/*
* Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.63 2017/10/28 00:37:13 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_balloc.c,v 1.64 2020/04/18 19:18:34 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -72,6 +72,12 @@
static int ffs_balloc_ufs2(struct vnode *, off_t, int, kauth_cred_t, int,
struct buf **);
+static daddr_t
+ffs_extb(struct fs *fs, struct ufs2_dinode *dp, daddr_t nb)
+{
+ return ufs_rw64(dp->di_extb[nb], UFS_FSNEEDSWAP(fs));
+}
+
/*
* Balloc defines the structure of file system storage
* by allocating the physical blocks on a device given
@@ -139,10 +145,11 @@
osize = ffs_blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
mutex_enter(&ump->um_lock);
- error = ffs_realloccg(ip, nb,
+ error = ffs_realloccg(ip, nb, ffs_getdb(fs, ip, nb),
ffs_blkpref_ufs1(ip, lastlbn, nb, flags,
&ip->i_ffs1_db[0]),
- osize, (int)fs->fs_bsize, cred, bpp, &newb);
+ osize, (int)fs->fs_bsize, flags, cred, bpp,
+ &newb);
if (error)
return (error);
ip->i_size = ffs_lblktosize(fs, nb + 1);
@@ -215,9 +222,10 @@
*/
mutex_enter(&ump->um_lock);
error = ffs_realloccg(ip, lbn,
+ ffs_getdb(fs, ip, lbn),
ffs_blkpref_ufs1(ip, lbn, (int)lbn, flags,
&ip->i_ffs1_db[0]),
- osize, nsize, cred, bpp, &newb);
+ osize, nsize, flags, cred, bpp, &newb);
if (error)
return (error);
}
@@ -543,11 +551,11 @@
if (lbn < 0)
return (EFBIG);
-#ifdef notyet
/*
* Check for allocating external data.
*/
if (flags & IO_EXT) {
+ struct ufs2_dinode *dp = ip->i_din.ffs2_din;
if (lbn >= UFS_NXADDR)
return (EFBIG);
/*
@@ -562,16 +570,15 @@
if (osize < fs->fs_bsize && osize > 0) {
mutex_enter(&ump->um_lock);
error = ffs_realloccg(ip, -1 - nb,
- dp->di_extb[nb],
+ ffs_extb(fs, dp, nb),
ffs_blkpref_ufs2(ip, lastlbn, (int)nb,
flags, &dp->di_extb[0]),
- osize,
- (int)fs->fs_bsize, cred, &bp);
+ osize, (int)fs->fs_bsize, flags, cred,
+ &bp, &newb);
if (error)
return (error);
- dp->di_extsize = smalllblktosize(fs, nb + 1);
+ dp->di_extsize = ffs_lblktosize(fs, nb + 1);
dp->di_extb[nb] = FFS_DBTOFSB(fs, bp->b_blkno);
- bp->b_xflags |= BX_ALTDATA;
ip->i_flag |= IN_CHANGE | IN_UPDATE;
if (flags & IO_SYNC)
bwrite(bp);
@@ -582,19 +589,16 @@
/*
* All blocks are direct blocks
*/
- if (flags & BA_METAONLY)
- panic("ffs_balloc_ufs2: BA_METAONLY for ext block");
nb = dp->di_extb[lbn];
- if (nb != 0 && dp->di_extsize >= smalllblktosize(fs, lbn + 1)) {
+ if (nb != 0 && dp->di_extsize >= ffs_lblktosize(fs, lbn + 1)) {
error = bread(vp, -1 - lbn, fs->fs_bsize,
0, &bp);
if (error) {
return (error);
}
- mutex_enter(&bp->b_interlock);
+ mutex_enter(bp->b_objlock);
bp->b_blkno = FFS_FSBTODB(fs, nb);
- bp->b_xflags |= BX_ALTDATA;
- mutex_exit(&bp->b_interlock);
+ mutex_exit(bp->b_objlock);
*bpp = bp;
return (0);
}
@@ -610,23 +614,21 @@
if (error) {
return (error);
}
- mutex_enter(&bp->b_interlock);
+ mutex_enter(bp->b_objlock);
bp->b_blkno = FFS_FSBTODB(fs, nb);
- bp->b_xflags |= BX_ALTDATA;
- mutex_exit(&bp->b_interlock);
+ mutex_exit(bp->b_objlock);
} else {
mutex_enter(&ump->um_lock);
error = ffs_realloccg(ip, -1 - lbn,
- dp->di_extb[lbn],
+ ffs_extb(fs, dp, lbn),
ffs_blkpref_ufs2(ip, lbn, (int)lbn, flags,
&dp->di_extb[0]),
- osize, nsize, cred, &bp);
+ osize, nsize, flags, cred, &bp, &newb);
if (error)
return (error);
- bp->b_xflags |= BX_ALTDATA;
}
} else {
- if (dp->di_extsize < smalllblktosize(fs, lbn + 1))
+ if (dp->di_extsize < ffs_lblktosize(fs, lbn + 1))
nsize = ffs_fragroundup(fs, size);
else
nsize = fs->fs_bsize;
@@ -641,14 +643,12 @@
nsize, (flags & B_CLRBUF) != 0, &bp);
if (error)
return error;
- bp->b_xflags |= BX_ALTDATA;
}
dp->di_extb[lbn] = FFS_DBTOFSB(fs, bp->b_blkno);
ip->i_flag |= IN_CHANGE | IN_UPDATE;
*bpp = bp;
return (0);
}
-#endif
/*
* If the next write will extend the file into a new block,
* and the file is currently composed of a fragment
@@ -661,10 +661,11 @@
osize = ffs_blksize(fs, ip, nb);
if (osize < fs->fs_bsize && osize > 0) {
mutex_enter(&ump->um_lock);
- error = ffs_realloccg(ip, nb,
+ error = ffs_realloccg(ip, nb, ffs_getdb(fs, ip, lbn),
ffs_blkpref_ufs2(ip, lastlbn, nb, flags,
&ip->i_ffs2_db[0]),
- osize, (int)fs->fs_bsize, cred, bpp, &newb);
+ osize, (int)fs->fs_bsize, flags, cred, bpp,
+ &newb);
if (error)
return (error);
ip->i_size = ffs_lblktosize(fs, nb + 1);
@@ -737,9 +738,10 @@
*/
mutex_enter(&ump->um_lock);
error = ffs_realloccg(ip, lbn,
+ ffs_getdb(fs, ip, lbn),
ffs_blkpref_ufs2(ip, lbn, (int)lbn, flags,
&ip->i_ffs2_db[0]),
- osize, nsize, cred, bpp, &newb);
Home |
Main Index |
Thread Index |
Old Index