aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/balloc.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>2008-07-11 19:27:31 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-07-11 19:27:31 -0400
commit7061eba75ceb0835ba61e7cbd757a6f9c1e4af92 (patch)
tree9c70df3078c0543573a9f38bb60c6b0f54608c7a /fs/ext4/balloc.c
parent6afd670713c9e7d5c5550e379dfedca8ffab4c90 (diff)
ext4: Use inode preallocation with -o noextents
When mballoc is enabled, block allocation for old block-based files are allocated using mballoc allocator instead of old block-based allocator. The old ext3 block reservation is turned off when mballoc is turned on. However, the in-core preallocation is not enabled for block-based/ non-extent based file block allocation. This result in performance regression, as now we don't have "reservation" ore in-core preallocation to prevent interleaved fragmentation in multiple writes workload. This patch fix this by enable per inode in-core preallocation for non extent files when mballoc is used. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r--fs/ext4/balloc.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 1327ac3a04de..816f1dbaeb3c 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -1923,7 +1923,7 @@ out:
1923 return 0; 1923 return 0;
1924} 1924}
1925 1925
1926ext4_fsblk_t ext4_new_block(handle_t *handle, struct inode *inode, 1926ext4_fsblk_t ext4_new_meta_block(handle_t *handle, struct inode *inode,
1927 ext4_fsblk_t goal, int *errp) 1927 ext4_fsblk_t goal, int *errp)
1928{ 1928{
1929 struct ext4_allocation_request ar; 1929 struct ext4_allocation_request ar;
@@ -1942,9 +1942,29 @@ ext4_fsblk_t ext4_new_block(handle_t *handle, struct inode *inode,
1942 ret = ext4_mb_new_blocks(handle, &ar, errp); 1942 ret = ext4_mb_new_blocks(handle, &ar, errp);
1943 return ret; 1943 return ret;
1944} 1944}
1945ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
1946 ext4_fsblk_t goal, unsigned long *count, int *errp)
1947{
1948 struct ext4_allocation_request ar;
1949 ext4_fsblk_t ret;
1950
1951 if (!test_opt(inode->i_sb, MBALLOC)) {
1952 ret = ext4_new_blocks_old(handle, inode, goal, count, errp);
1953 return ret;
1954 }
1955
1956 memset(&ar, 0, sizeof(ar));
1957 ar.inode = inode;
1958 ar.goal = goal;
1959 ar.len = *count;
1960 ret = ext4_mb_new_blocks(handle, &ar, errp);
1961 *count = ar.len;
1962 return ret;
1963}
1945 1964
1946ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode, 1965ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
1947 ext4_fsblk_t goal, unsigned long *count, int *errp) 1966 ext4_lblk_t iblock, ext4_fsblk_t goal,
1967 unsigned long *count, int *errp)
1948{ 1968{
1949 struct ext4_allocation_request ar; 1969 struct ext4_allocation_request ar;
1950 ext4_fsblk_t ret; 1970 ext4_fsblk_t ret;
@@ -1955,9 +1975,21 @@ ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,
1955 } 1975 }
1956 1976
1957 memset(&ar, 0, sizeof(ar)); 1977 memset(&ar, 0, sizeof(ar));
1978 /* Fill with neighbour allocated blocks */
1979 ar.lleft = 0;
1980 ar.pleft = 0;
1981 ar.lright = 0;
1982 ar.pright = 0;
1983
1958 ar.inode = inode; 1984 ar.inode = inode;
1959 ar.goal = goal; 1985 ar.goal = goal;
1960 ar.len = *count; 1986 ar.len = *count;
1987 ar.logical = iblock;
1988 if (S_ISREG(inode->i_mode))
1989 ar.flags = EXT4_MB_HINT_DATA;
1990 else
1991 /* disable in-core preallocation for non-regular files */
1992 ar.flags = 0;
1961 ret = ext4_mb_new_blocks(handle, &ar, errp); 1993 ret = ext4_mb_new_blocks(handle, &ar, errp);
1962 *count = ar.len; 1994 *count = ar.len;
1963 return ret; 1995 return ret;