From 9e880b876dea266a295d6f114724ba88bde68cbb Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 28 Apr 2011 14:27:17 +0000 Subject: Sync with several changes in UFS/FFS: - 77115: Implement support for O_DIRECT. - 98425: Fix a performance issue introduced in 70131 that was causing reads before writes even when writing full blocks. - 98658: Rename the BALLOC flags from B_* to BA_* to avoid confusion with the struct buf B_ flags. - 100344: Merge the BA_ and IO_ flags so so that they may both be used in the same flags word. This merger is possible by assigning the IO_ flags to the low sixteen bits and the BA_ flags the high sixteen bits. - 105422: Fix a file-rewrite performance case. - 129545: Implement IO_INVAL in VOP_WRITE() by marking the buffer as "no cache". - Readd the DOINGASYNC() macro and use it to control asynchronous writes. Change i-node updates to honor DOINGASYNC() instead of always being synchronous. - Use a PRIV_VFS_RETAINSUGID check instead of checking cr_uid against 0 directly when deciding whether or not to clear suid and sgid bits. Submitted by: Pedro F. Giffuni giffunip at yahoo --- sys/fs/ext2fs/ext2_balloc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'sys/fs/ext2fs/ext2_balloc.c') diff --git a/sys/fs/ext2fs/ext2_balloc.c b/sys/fs/ext2fs/ext2_balloc.c index 124ac32ddf1c..3fb19763d530 100644 --- a/sys/fs/ext2fs/ext2_balloc.c +++ b/sys/fs/ext2fs/ext2_balloc.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -143,7 +143,7 @@ ext2_balloc(ip, lbn, size, cred, bpp, flags) return (error); bp = getblk(vp, lbn, nsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); - if (flags & B_CLRBUF) + if (flags & BA_CLRBUF) vfs_bio_clrbuf(bp); } ip->i_db[lbn] = dbtofsb(fs, bp->b_blkno); @@ -235,7 +235,7 @@ ext2_balloc(ip, lbn, size, cred, bpp, flags) * If required, write synchronously, otherwise use * delayed write. */ - if (flags & B_SYNC) { + if (flags & IO_SYNC) { bwrite(bp); } else { if (bp->b_bufsize == fs->e2fs_bsize) @@ -258,14 +258,14 @@ ext2_balloc(ip, lbn, size, cred, bpp, flags) nb = newb; nbp = getblk(vp, lbn, fs->e2fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); - if (flags & B_CLRBUF) + if (flags & BA_CLRBUF) vfs_bio_clrbuf(nbp); bap[indirs[i].in_off] = nb; /* * If required, write synchronously, otherwise use * delayed write. */ - if (flags & B_SYNC) { + if (flags & IO_SYNC) { bwrite(bp); } else { if (bp->b_bufsize == fs->e2fs_bsize) @@ -276,8 +276,15 @@ ext2_balloc(ip, lbn, size, cred, bpp, flags) return (0); } brelse(bp); - if (flags & B_CLRBUF) { - error = bread(vp, lbn, (int)fs->e2fs_bsize, NOCRED, &nbp); + if (flags & BA_CLRBUF) { + int seqcount = (flags & BA_SEQMASK) >> BA_SEQSHIFT; + if (seqcount && (vp->v_mount->mnt_flag & MNT_NOCLUSTERR) == 0) { + error = cluster_read(vp, ip->i_size, lbn, + (int)fs->e2fs_bsize, NOCRED, + MAXBSIZE, seqcount, &nbp); + } else { + error = bread(vp, lbn, (int)fs->e2fs_bsize, NOCRED, &nbp); + } if (error) { brelse(nbp); return (error); -- cgit v1.2.3