@@ -128,25 +128,9 @@ static int ntfs_extend_initialized_size(struct file *file,
128
128
goto out ;
129
129
130
130
if (lcn == SPARSE_LCN ) {
131
- loff_t vbo = (loff_t )vcn << bits ;
132
- loff_t to = vbo + ((loff_t )clen << bits );
133
-
134
- if (to <= new_valid ) {
135
- ni -> i_valid = to ;
136
- pos = to ;
137
- goto next ;
138
- }
139
-
140
- if (vbo < pos ) {
141
- pos = vbo ;
142
- } else {
143
- to = (new_valid >> bits ) << bits ;
144
- if (pos < to ) {
145
- ni -> i_valid = to ;
146
- pos = to ;
147
- goto next ;
148
- }
149
- }
131
+ pos = ((loff_t )clen + vcn ) << bits ;
132
+ ni -> i_valid = pos ;
133
+ goto next ;
150
134
}
151
135
}
152
136
@@ -279,8 +263,9 @@ void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn,
279
263
{
280
264
struct address_space * mapping = inode -> i_mapping ;
281
265
struct ntfs_sb_info * sbi = inode -> i_sb -> s_fs_info ;
282
- u64 vbo = (u64 )vcn << sbi -> cluster_bits ;
283
- u64 bytes = (u64 )len << sbi -> cluster_bits ;
266
+ u8 cluster_bits = sbi -> cluster_bits ;
267
+ u64 vbo = (u64 )vcn << cluster_bits ;
268
+ u64 bytes = (u64 )len << cluster_bits ;
284
269
u32 blocksize = 1 << inode -> i_blkbits ;
285
270
pgoff_t idx0 = page0 ? page0 -> index : -1 ;
286
271
loff_t vbo_clst = vbo & sbi -> cluster_mask_inv ;
@@ -329,19 +314,17 @@ void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn,
329
314
330
315
zero_user_segment (page , from , to );
331
316
332
- if (!partial ) {
333
- if (!PageUptodate (page ))
334
- SetPageUptodate (page );
335
- set_page_dirty (page );
336
- }
317
+ if (!partial )
318
+ SetPageUptodate (page );
319
+ flush_dcache_page (page );
320
+ set_page_dirty (page );
337
321
338
322
if (idx != idx0 ) {
339
323
unlock_page (page );
340
324
put_page (page );
341
325
}
342
326
cond_resched ();
343
327
}
344
- mark_inode_dirty (inode );
345
328
}
346
329
347
330
/*
@@ -588,11 +571,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
588
571
u32 frame_size ;
589
572
loff_t mask , vbo_a , end_a , tmp ;
590
573
591
- err = filemap_write_and_wait_range (mapping , vbo , end - 1 );
592
- if (err )
593
- goto out ;
594
-
595
- err = filemap_write_and_wait_range (mapping , end , LLONG_MAX );
574
+ err = filemap_write_and_wait_range (mapping , vbo , LLONG_MAX );
596
575
if (err )
597
576
goto out ;
598
577
@@ -693,7 +672,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
693
672
goto out ;
694
673
695
674
if (is_supported_holes ) {
696
- CLST vcn_v = ni -> i_valid >> sbi -> cluster_bits ;
675
+ CLST vcn_v = bytes_to_cluster ( sbi , ni -> i_valid ) ;
697
676
CLST vcn = vbo >> sbi -> cluster_bits ;
698
677
CLST cend = bytes_to_cluster (sbi , end );
699
678
CLST lcn , clen ;
0 commit comments