diff options
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r-- | fs/ext4/balloc.c | 36 |
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 | ||
1926 | ext4_fsblk_t ext4_new_block(handle_t *handle, struct inode *inode, | 1926 | ext4_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 | } |
1945 | ext4_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 | ||
1946 | ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode, | 1965 | ext4_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; |