PERFORCE change 190774 for review
Zheng Liu
lz at FreeBSD.org
Fri Apr 1 16:32:55 UTC 2011
http://p4web.freebsd.org/@@190774?ac=10
Change 190774 by lz at freebsd-dev on 2011/03/30 12:39:16
Rename ext2_alloc_rsv() to ext2_prealloc and call ext2_alloc() in ext2_balloc.c.
* Rename ext2_alloc_rsv() to ext2_prealloc()
* Call ext2_alloc() to allocate a block
* Rename 'rsv' to 'doprealloc' and 'rsv_winsize' to 'prealloc_size'
Affected files ...
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#42 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_balloc.c#8 edit
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.c#1 add
.. //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.h#2 edit
.. //depot/projects/soc2010/extfs/src/sys/modules/ext2fs/Makefile#2 edit
Differences ...
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_alloc.c#42 (text+ko) ====
@@ -101,11 +101,11 @@
SYSCTL_NODE(_vfs, OID_AUTO, ext2fs, CTLFLAG_RW, 0, "EXT2FS filesystem");
-static int rsv = 0;
-SYSCTL_INT(_vfs_ext2fs, OID_AUTO, rsv, CTLFLAG_RW, &rsv, 0, "");
+static int doprealloc = 0;
+SYSCTL_INT(_vfs_ext2fs, OID_AUTO, doprealloc, CTLFLAG_RW, &doprealloc, 0, "");
-static int rsv_winsize = 8;
-SYSCTL_UINT(_vfs_ext2fs, OID_AUTO, rsv_winsize, CTLFLAG_RW, &rsv_winsize, 0, "");
+static int prealloc_size = 8;
+SYSCTL_UINT(_vfs_ext2fs, OID_AUTO, prealloc_size, CTLFLAG_RW, &prealloc_size, 0, "");
/*
* Allocate a free block.
@@ -222,8 +222,8 @@
rp->rsv_start = EXT2_RSV_NOT_ALLOCATED;
rp->rsv_end = EXT2_RSV_NOT_ALLOCATED;
- if (rsv_winsize < EXT2_RSV_MAX_RESERVE_BLKS)
- rp->rsv_goal_size = rsv_winsize;
+ if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
+ rp->rsv_goal_size = prealloc_size;
else
rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
rp->rsv_alloc_hit = 0;
@@ -255,8 +255,8 @@
EXT2_TREE_LOCK(ip->i_e2fs);
ext2_remove_rsv_win(ip->i_e2fs, rp);
EXT2_TREE_UNLOCK(ip->i_e2fs);
- if (rsv_winsize < EXT2_RSV_MAX_RESERVE_BLKS)
- rp->rsv_goal_size = rsv_winsize;
+ if (prealloc_size < EXT2_RSV_MAX_RESERVE_BLKS)
+ rp->rsv_goal_size = prealloc_size;
else
rp->rsv_goal_size = EXT2_RSV_DEFAULT_RESERVE_BLKS;
}
@@ -496,12 +496,10 @@
/*
* Allocate a block using reservation window in ext2 file system.
- *
- * XXX: This function will replace the ext2_alloc() function.
*/
int
-ext2_alloc_rsv(struct inode *ip, int32_t lbn, int32_t bpref,
- int size, struct ucred *cred, int32_t *bnp)
+ext2_prealloc(struct inode *ip, int32_t lbn, int32_t bpref,
+ int size, struct ucred *cred)
{
struct m_ext2fs *fs;
struct ext2mount *ump;
@@ -509,16 +507,15 @@
int32_t bno = 0;
int i, cg, error;
- *bnp = 0;
fs = ip->i_e2fs;
ump = ip->i_ump;
mtx_assert(EXT2_MTX(ump), MA_OWNED);
if (size == fs->e2fs_bsize && fs->e2fs->e2fs_fbcount == 0)
- goto nospace;
+ goto fail;
if (cred->cr_uid != 0 &&
fs->e2fs->e2fs_fbcount < fs->e2fs->e2fs_rbcount)
- goto nospace;
+ goto fail;
if (bpref >= fs->e2fs->e2fs_bcount)
bpref = 0;
@@ -526,11 +523,6 @@
cg = ino_to_cg(fs, ip->i_number);
else
cg = dtog(fs, bpref);
- if (rsv == 0) {
- bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize,
- ext2_alloccg);
- goto allocated;
- }
/* If cg has some free blocks, then try to allocate a free block from this cg */
if (fs->e2fs_gd[cg].ext2bgd_nbfree > 0) {
@@ -541,7 +533,7 @@
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
- goto ioerror;
+ goto fail;
}
EXT2_RSV_LOCK(ip);
@@ -566,7 +558,7 @@
(int)fs->e2fs_bsize, NOCRED, &bp);
if (error) {
brelse(bp);
- goto ioerror;
+ goto fail;
}
EXT2_RSV_LOCK(ip);
@@ -585,26 +577,11 @@
}
allocated:
- if (bno > 0) {
- ip->i_next_alloc_block = lbn;
- ip->i_next_alloc_goal = bno;
+ if (bno > 0)
+ return (bno);
- ip->i_blocks += btodb(fs->e2fs_bsize);
- ip->i_flag |= IN_CHANGE | IN_UPDATE;
- *bnp = bno;
- return (0);
- }
-
-nospace:
- EXT2_UNLOCK(ump);
- ext2_fserr(fs, cred->cr_uid, "file system full");
- uprintf("\n%s: write failed, file system is full\n", fs->e2fs_fsmnt);
- return (ENOSPC);
-
-ioerror:
- ext2_fserr(fs, cred->cr_uid, "file system IO error");
- uprintf("\n%s: write failed, file system IO error\n", fs->e2fs_fsmnt);
- return (EIO);
+fail:
+ return (0);
}
int
@@ -643,8 +620,11 @@
cg = ino_to_cg(fs, ip->i_number);
else
cg = dtog(fs, bpref);
- bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize,
- ext2_alloccg);
+ if (doprealloc == 1)
+ bno = (daddr_t)ext2_prealloc(ip, lbn, bpref, size, cred);
+ else
+ bno = (daddr_t)ext2_hashalloc(ip, cg, bpref, fs->e2fs_bsize,
+ ext2_alloccg);
if (bno > 0) {
/* set next_alloc fields as done in block_getblk */
ip->i_next_alloc_block = lbn;
@@ -1623,7 +1603,7 @@
loc = skpc(0xff, len, &bbp[start]);
if (loc == 0) {
/* XXX: just for reservation window */
- if (rsv == 1)
+ if (doprealloc == 1)
return (-1);
else {
printf("start = %d, len = %d, fs = %s\n",
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_balloc.c#8 (text+ko) ====
@@ -141,7 +141,7 @@
else
nsize = fs->e2fs_bsize;
EXT2_LOCK(ump);
- error = ext2_alloc_rsv(ip, lbn,
+ error = ext2_alloc(ip, lbn,
ext2_blkpref(ip, lbn, (int)lbn, &ip->i_db[0], 0),
nsize, cred, &newb);
if (error)
@@ -175,7 +175,7 @@
EXT2_LOCK(ump);
pref = ext2_blkpref(ip, lbn, indirs[0].in_off +
EXT2_NDIR_BLOCKS, &ip->i_db[0], 0);
- if ((error = ext2_alloc_rsv(ip, lbn, pref,
+ if ((error = ext2_alloc(ip, lbn, pref,
(int)fs->e2fs_bsize, cred, &newb)))
return (error);
nb = newb;
@@ -216,7 +216,7 @@
if (pref == 0)
pref = ext2_blkpref(ip, lbn, indirs[i].in_off, bap,
bp->b_lblkno);
- error = ext2_alloc_rsv(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newb);
+ error = ext2_alloc(ip, lbn, pref, (int)fs->e2fs_bsize, cred, &newb);
if (error) {
brelse(bp);
return (error);
@@ -255,7 +255,7 @@
EXT2_LOCK(ump);
pref = ext2_blkpref(ip, lbn, indirs[i].in_off, &bap[0],
bp->b_lblkno);
- if ((error = ext2_alloc_rsv(ip, lbn, pref,
+ if ((error = ext2_alloc(ip, lbn, pref,
(int)fs->e2fs_bsize, cred, &newb)) != 0) {
brelse(bp);
return (error);
==== //depot/projects/soc2010/extfs/src/sys/fs/ext2fs/ext2_prealloc.h#2 (text+ko) ====
@@ -73,6 +73,6 @@
/* ext2_alloc.c */
void ext2_init_rsv(struct inode *ip);
void ext2_discard_rsv(struct inode *ip);
-int ext2_alloc_rsv(struct inode *, int32_t, int32_t, int, struct ucred *, int32_t *);
+int ext2_prealloc(struct inode *, int32_t, int32_t, int, struct ucred *);
#endif /* !_FS_EXT2FS_EXT2_PREALLOC_H_ */
==== //depot/projects/soc2010/extfs/src/sys/modules/ext2fs/Makefile#2 (text+ko) ====
@@ -4,7 +4,7 @@
KMOD= ext2fs
SRCS= opt_ddb.h opt_quota.h opt_suiddir.h vnode_if.h \
ext2_alloc.c ext2_balloc.c ext2_bmap.c ext2_inode.c \
- ext2_inode_cnv.c ext2_lookup.c ext2_subr.c ext2_vfsops.c \
- ext2_vnops.c
+ ext2_inode_cnv.c ext2_lookup.c ext2_prealloc.c \
+ ext2_subr.c ext2_vfsops.c ext2_vnops.c
.include <bsd.kmod.mk>
More information about the p4-projects
mailing list