diff options
Diffstat (limited to 'fs/ocfs2/refcounttree.c')
-rw-r--r-- | fs/ocfs2/refcounttree.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 4793f36f6518..73a11ccfd4c2 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
@@ -2436,16 +2436,26 @@ static int ocfs2_calc_refcount_meta_credits(struct super_block *sb, | |||
2436 | len = min((u64)cpos + clusters, le64_to_cpu(rec.r_cpos) + | 2436 | len = min((u64)cpos + clusters, le64_to_cpu(rec.r_cpos) + |
2437 | le32_to_cpu(rec.r_clusters)) - cpos; | 2437 | le32_to_cpu(rec.r_clusters)) - cpos; |
2438 | /* | 2438 | /* |
2439 | * If the refcount rec already exist, cool. We just need | ||
2440 | * to check whether there is a split. Otherwise we just need | ||
2441 | * to increase the refcount. | ||
2442 | * If we will insert one, increases recs_add. | ||
2443 | * | ||
2444 | * We record all the records which will be inserted to the | 2439 | * We record all the records which will be inserted to the |
2445 | * same refcount block, so that we can tell exactly whether | 2440 | * same refcount block, so that we can tell exactly whether |
2446 | * we need a new refcount block or not. | 2441 | * we need a new refcount block or not. |
2442 | * | ||
2443 | * If we will insert a new one, this is easy and only happens | ||
2444 | * during adding refcounted flag to the extent, so we don't | ||
2445 | * have a chance of spliting. We just need one record. | ||
2446 | * | ||
2447 | * If the refcount rec already exists, that would be a little | ||
2448 | * complicated. we may have to: | ||
2449 | * 1) split at the beginning if the start pos isn't aligned. | ||
2450 | * we need 1 more record in this case. | ||
2451 | * 2) split int the end if the end pos isn't aligned. | ||
2452 | * we need 1 more record in this case. | ||
2453 | * 3) split in the middle because of file system fragmentation. | ||
2454 | * we need 2 more records in this case(we can't detect this | ||
2455 | * beforehand, so always think of the worst case). | ||
2447 | */ | 2456 | */ |
2448 | if (rec.r_refcount) { | 2457 | if (rec.r_refcount) { |
2458 | recs_add += 2; | ||
2449 | /* Check whether we need a split at the beginning. */ | 2459 | /* Check whether we need a split at the beginning. */ |
2450 | if (cpos == start_cpos && | 2460 | if (cpos == start_cpos && |
2451 | cpos != le64_to_cpu(rec.r_cpos)) | 2461 | cpos != le64_to_cpu(rec.r_cpos)) |
@@ -2931,6 +2941,12 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle, | |||
2931 | 2941 | ||
2932 | offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; | 2942 | offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; |
2933 | end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits); | 2943 | end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits); |
2944 | /* | ||
2945 | * We only duplicate pages until we reach the page contains i_size - 1. | ||
2946 | * So trim 'end' to i_size. | ||
2947 | */ | ||
2948 | if (end > i_size_read(context->inode)) | ||
2949 | end = i_size_read(context->inode); | ||
2934 | 2950 | ||
2935 | while (offset < end) { | 2951 | while (offset < end) { |
2936 | page_index = offset >> PAGE_CACHE_SHIFT; | 2952 | page_index = offset >> PAGE_CACHE_SHIFT; |
@@ -4166,6 +4182,12 @@ static int __ocfs2_reflink(struct dentry *old_dentry, | |||
4166 | struct inode *inode = old_dentry->d_inode; | 4182 | struct inode *inode = old_dentry->d_inode; |
4167 | struct buffer_head *new_bh = NULL; | 4183 | struct buffer_head *new_bh = NULL; |
4168 | 4184 | ||
4185 | if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) { | ||
4186 | ret = -EINVAL; | ||
4187 | mlog_errno(ret); | ||
4188 | goto out; | ||
4189 | } | ||
4190 | |||
4169 | ret = filemap_fdatawrite(inode->i_mapping); | 4191 | ret = filemap_fdatawrite(inode->i_mapping); |
4170 | if (ret) { | 4192 | if (ret) { |
4171 | mlog_errno(ret); | 4193 | mlog_errno(ret); |