aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-09-21 12:52:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-09-21 12:52:20 -0400
commit73e83dc300d5f2858c1e3f6bf7fbb1e161a2990c (patch)
treefb2df8f427a7578c522aead5e57e27be78ea125e /fs
parent176df2457ef6207156ca1a40991c54ca01fef567 (diff)
parent813d974c53a2b353566a86bb127625b403696dae (diff)
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2: ocfs2: Pack vote message and response structures ocfs2: Don't double set write parameters ocfs2: Fix pos/len passed to ocfs2_write_cluster ocfs2: Allow smaller allocations during large writes
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/aops.c33
-rw-r--r--fs/ocfs2/file.c4
-rw-r--r--fs/ocfs2/localalloc.c4
-rw-r--r--fs/ocfs2/localalloc.h2
-rw-r--r--fs/ocfs2/suballoc.c29
-rw-r--r--fs/ocfs2/suballoc.h11
-rw-r--r--fs/ocfs2/vote.c4
7 files changed, 57 insertions, 30 deletions
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 50cd8a209012..f37f25c931f5 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -930,18 +930,11 @@ static void ocfs2_write_failure(struct inode *inode,
930 loff_t user_pos, unsigned user_len) 930 loff_t user_pos, unsigned user_len)
931{ 931{
932 int i; 932 int i;
933 unsigned from, to; 933 unsigned from = user_pos & (PAGE_CACHE_SIZE - 1),
934 to = user_pos + user_len;
934 struct page *tmppage; 935 struct page *tmppage;
935 936
936 ocfs2_zero_new_buffers(wc->w_target_page, user_pos, user_len); 937 ocfs2_zero_new_buffers(wc->w_target_page, from, to);
937
938 if (wc->w_large_pages) {
939 from = wc->w_target_from;
940 to = wc->w_target_to;
941 } else {
942 from = 0;
943 to = PAGE_CACHE_SIZE;
944 }
945 938
946 for(i = 0; i < wc->w_num_pages; i++) { 939 for(i = 0; i < wc->w_num_pages; i++) {
947 tmppage = wc->w_pages[i]; 940 tmppage = wc->w_pages[i];
@@ -991,9 +984,6 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno,
991 map_from = cluster_start; 984 map_from = cluster_start;
992 map_to = cluster_end; 985 map_to = cluster_end;
993 } 986 }
994
995 wc->w_target_from = map_from;
996 wc->w_target_to = map_to;
997 } else { 987 } else {
998 /* 988 /*
999 * If we haven't allocated the new page yet, we 989 * If we haven't allocated the new page yet, we
@@ -1211,18 +1201,33 @@ static int ocfs2_write_cluster_by_desc(struct address_space *mapping,
1211 loff_t pos, unsigned len) 1201 loff_t pos, unsigned len)
1212{ 1202{
1213 int ret, i; 1203 int ret, i;
1204 loff_t cluster_off;
1205 unsigned int local_len = len;
1214 struct ocfs2_write_cluster_desc *desc; 1206 struct ocfs2_write_cluster_desc *desc;
1207 struct ocfs2_super *osb = OCFS2_SB(mapping->host->i_sb);
1215 1208
1216 for (i = 0; i < wc->w_clen; i++) { 1209 for (i = 0; i < wc->w_clen; i++) {
1217 desc = &wc->w_desc[i]; 1210 desc = &wc->w_desc[i];
1218 1211
1212 /*
1213 * We have to make sure that the total write passed in
1214 * doesn't extend past a single cluster.
1215 */
1216 local_len = len;
1217 cluster_off = pos & (osb->s_clustersize - 1);
1218 if ((cluster_off + local_len) > osb->s_clustersize)
1219 local_len = osb->s_clustersize - cluster_off;
1220
1219 ret = ocfs2_write_cluster(mapping, desc->c_phys, 1221 ret = ocfs2_write_cluster(mapping, desc->c_phys,
1220 desc->c_unwritten, data_ac, meta_ac, 1222 desc->c_unwritten, data_ac, meta_ac,
1221 wc, desc->c_cpos, pos, len); 1223 wc, desc->c_cpos, pos, local_len);
1222 if (ret) { 1224 if (ret) {
1223 mlog_errno(ret); 1225 mlog_errno(ret);
1224 goto out; 1226 goto out;
1225 } 1227 }
1228
1229 len -= local_len;
1230 pos += local_len;
1226 } 1231 }
1227 1232
1228 ret = 0; 1233 ret = 0;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 7e34e66159c6..f3bc3658e7a5 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -491,8 +491,8 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb,
491 goto leave; 491 goto leave;
492 } 492 }
493 493
494 status = ocfs2_claim_clusters(osb, handle, data_ac, 1, 494 status = __ocfs2_claim_clusters(osb, handle, data_ac, 1,
495 &bit_off, &num_bits); 495 clusters_to_add, &bit_off, &num_bits);
496 if (status < 0) { 496 if (status < 0) {
497 if (status != -ENOSPC) 497 if (status != -ENOSPC)
498 mlog_errno(status); 498 mlog_errno(status);
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 545f7892cdf3..de984d272576 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -524,13 +524,12 @@ bail:
524int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 524int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
525 handle_t *handle, 525 handle_t *handle,
526 struct ocfs2_alloc_context *ac, 526 struct ocfs2_alloc_context *ac,
527 u32 min_bits, 527 u32 bits_wanted,
528 u32 *bit_off, 528 u32 *bit_off,
529 u32 *num_bits) 529 u32 *num_bits)
530{ 530{
531 int status, start; 531 int status, start;
532 struct inode *local_alloc_inode; 532 struct inode *local_alloc_inode;
533 u32 bits_wanted;
534 void *bitmap; 533 void *bitmap;
535 struct ocfs2_dinode *alloc; 534 struct ocfs2_dinode *alloc;
536 struct ocfs2_local_alloc *la; 535 struct ocfs2_local_alloc *la;
@@ -538,7 +537,6 @@ int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
538 mlog_entry_void(); 537 mlog_entry_void();
539 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL); 538 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL);
540 539
541 bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
542 local_alloc_inode = ac->ac_inode; 540 local_alloc_inode = ac->ac_inode;
543 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; 541 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data;
544 la = OCFS2_LOCAL_ALLOC(alloc); 542 la = OCFS2_LOCAL_ALLOC(alloc);
diff --git a/fs/ocfs2/localalloc.h b/fs/ocfs2/localalloc.h
index 385a10152f9c..3f76631e110c 100644
--- a/fs/ocfs2/localalloc.h
+++ b/fs/ocfs2/localalloc.h
@@ -48,7 +48,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
48int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, 48int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb,
49 handle_t *handle, 49 handle_t *handle,
50 struct ocfs2_alloc_context *ac, 50 struct ocfs2_alloc_context *ac,
51 u32 min_bits, 51 u32 bits_wanted,
52 u32 *bit_off, 52 u32 *bit_off,
53 u32 *num_bits); 53 u32 *num_bits);
54 54
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index d9c5c9fcb30f..8f09f5235e3a 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1486,21 +1486,21 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1486 * contig. allocation, set to '1' to indicate we can deal with extents 1486 * contig. allocation, set to '1' to indicate we can deal with extents
1487 * of any size. 1487 * of any size.
1488 */ 1488 */
1489int ocfs2_claim_clusters(struct ocfs2_super *osb, 1489int __ocfs2_claim_clusters(struct ocfs2_super *osb,
1490 handle_t *handle, 1490 handle_t *handle,
1491 struct ocfs2_alloc_context *ac, 1491 struct ocfs2_alloc_context *ac,
1492 u32 min_clusters, 1492 u32 min_clusters,
1493 u32 *cluster_start, 1493 u32 max_clusters,
1494 u32 *num_clusters) 1494 u32 *cluster_start,
1495 u32 *num_clusters)
1495{ 1496{
1496 int status; 1497 int status;
1497 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; 1498 unsigned int bits_wanted = max_clusters;
1498 u64 bg_blkno = 0; 1499 u64 bg_blkno = 0;
1499 u16 bg_bit_off; 1500 u16 bg_bit_off;
1500 1501
1501 mlog_entry_void(); 1502 mlog_entry_void();
1502 1503
1503 BUG_ON(!ac);
1504 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); 1504 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1505 1505
1506 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL 1506 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
@@ -1557,6 +1557,19 @@ bail:
1557 return status; 1557 return status;
1558} 1558}
1559 1559
1560int ocfs2_claim_clusters(struct ocfs2_super *osb,
1561 handle_t *handle,
1562 struct ocfs2_alloc_context *ac,
1563 u32 min_clusters,
1564 u32 *cluster_start,
1565 u32 *num_clusters)
1566{
1567 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
1568
1569 return __ocfs2_claim_clusters(osb, handle, ac, min_clusters,
1570 bits_wanted, cluster_start, num_clusters);
1571}
1572
1560static inline int ocfs2_block_group_clear_bits(handle_t *handle, 1573static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1561 struct inode *alloc_inode, 1574 struct inode *alloc_inode,
1562 struct ocfs2_group_desc *bg, 1575 struct ocfs2_group_desc *bg,
diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h
index f212dc01a84b..cafe93703095 100644
--- a/fs/ocfs2/suballoc.h
+++ b/fs/ocfs2/suballoc.h
@@ -85,6 +85,17 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb,
85 u32 min_clusters, 85 u32 min_clusters,
86 u32 *cluster_start, 86 u32 *cluster_start,
87 u32 *num_clusters); 87 u32 *num_clusters);
88/*
89 * Use this variant of ocfs2_claim_clusters to specify a maxiumum
90 * number of clusters smaller than the allocation reserved.
91 */
92int __ocfs2_claim_clusters(struct ocfs2_super *osb,
93 handle_t *handle,
94 struct ocfs2_alloc_context *ac,
95 u32 min_clusters,
96 u32 max_clusters,
97 u32 *cluster_start,
98 u32 *num_clusters);
88 99
89int ocfs2_free_suballoc_bits(handle_t *handle, 100int ocfs2_free_suballoc_bits(handle_t *handle,
90 struct inode *alloc_inode, 101 struct inode *alloc_inode,
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c
index 66a13ee63d4c..c05358538f2b 100644
--- a/fs/ocfs2/vote.c
+++ b/fs/ocfs2/vote.c
@@ -66,7 +66,7 @@ struct ocfs2_vote_msg
66{ 66{
67 struct ocfs2_msg_hdr v_hdr; 67 struct ocfs2_msg_hdr v_hdr;
68 __be32 v_reserved1; 68 __be32 v_reserved1;
69}; 69} __attribute__ ((packed));
70 70
71/* Responses are given these values to maintain backwards 71/* Responses are given these values to maintain backwards
72 * compatibility with older ocfs2 versions */ 72 * compatibility with older ocfs2 versions */
@@ -78,7 +78,7 @@ struct ocfs2_response_msg
78{ 78{
79 struct ocfs2_msg_hdr r_hdr; 79 struct ocfs2_msg_hdr r_hdr;
80 __be32 r_response; 80 __be32 r_response;
81}; 81} __attribute__ ((packed));
82 82
83struct ocfs2_vote_work { 83struct ocfs2_vote_work {
84 struct list_head w_list; 84 struct list_head w_list;