Lines 588-594
Link Here
|
588 |
|
588 |
|
589 |
/* Unlock pages prepared by reiserfs_prepare_file_region_for_write */ |
589 |
/* Unlock pages prepared by reiserfs_prepare_file_region_for_write */ |
590 |
void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of locked pages */ |
590 |
void reiserfs_unprepare_pages(struct page **prepared_pages, /* list of locked pages */ |
591 |
int num_pages /* amount of pages */) { |
591 |
size_t num_pages /* amount of pages */) { |
592 |
int i; // loop counter |
592 |
int i; // loop counter |
593 |
|
593 |
|
594 |
for (i=0; i < num_pages ; i++) { |
594 |
for (i=0; i < num_pages ; i++) { |
Lines 619-625
Link Here
|
619 |
int offset; // offset in page |
619 |
int offset; // offset in page |
620 |
|
620 |
|
621 |
for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) { |
621 |
for ( i = 0, offset = (pos & (PAGE_CACHE_SIZE-1)); i < num_pages ; i++,offset=0) { |
622 |
int count = min_t(int,PAGE_CACHE_SIZE-offset,write_bytes); // How much of bytes to write to this page |
622 |
size_t count = min_t(size_t,PAGE_CACHE_SIZE-offset,write_bytes); // How much of bytes to write to this page |
623 |
struct page *page=prepared_pages[i]; // Current page we process. |
623 |
struct page *page=prepared_pages[i]; // Current page we process. |
624 |
|
624 |
|
625 |
fault_in_pages_readable( buf, count); |
625 |
fault_in_pages_readable( buf, count); |
Lines 718-725
Link Here
|
718 |
struct reiserfs_transaction_handle *th, |
718 |
struct reiserfs_transaction_handle *th, |
719 |
struct inode *inode, |
719 |
struct inode *inode, |
720 |
loff_t pos, /* Writing position offset */ |
720 |
loff_t pos, /* Writing position offset */ |
721 |
int num_pages, /* Number of pages to write */ |
721 |
size_t num_pages, /* Number of pages to write */ |
722 |
int write_bytes, /* number of bytes to write */ |
722 |
size_t write_bytes, /* number of bytes to write */ |
723 |
struct page **prepared_pages /* list of pages */ |
723 |
struct page **prepared_pages /* list of pages */ |
724 |
) |
724 |
) |
725 |
{ |
725 |
{ |
Lines 854-862
Link Here
|
854 |
static int reiserfs_prepare_file_region_for_write( |
854 |
static int reiserfs_prepare_file_region_for_write( |
855 |
struct inode *inode /* Inode of the file */, |
855 |
struct inode *inode /* Inode of the file */, |
856 |
loff_t pos, /* position in the file */ |
856 |
loff_t pos, /* position in the file */ |
857 |
int num_pages, /* number of pages to |
857 |
size_t num_pages, /* number of pages to |
858 |
prepare */ |
858 |
prepare */ |
859 |
int write_bytes, /* Amount of bytes to be |
859 |
size_t write_bytes, /* Amount of bytes to be |
860 |
overwritten from |
860 |
overwritten from |
861 |
@pos */ |
861 |
@pos */ |
862 |
struct page **prepared_pages /* pointer to array |
862 |
struct page **prepared_pages /* pointer to array |
Lines 1252-1261
Link Here
|
1252 |
while ( count > 0) { |
1252 |
while ( count > 0) { |
1253 |
/* This is the main loop in which we running until some error occures |
1253 |
/* This is the main loop in which we running until some error occures |
1254 |
or until we write all of the data. */ |
1254 |
or until we write all of the data. */ |
1255 |
int num_pages;/* amount of pages we are going to write this iteration */ |
1255 |
size_t num_pages;/* amount of pages we are going to write this iteration */ |
1256 |
int write_bytes; /* amount of bytes to write during this iteration */ |
1256 |
size_t write_bytes; /* amount of bytes to write during this iteration */ |
1257 |
int blocks_to_allocate; /* how much blocks we need to allocate for |
1257 |
size_t blocks_to_allocate; /* how much blocks we need to allocate for this iteration */ |
1258 |
this iteration */ |
|
|
1259 |
|
1258 |
|
1260 |
/* (pos & (PAGE_CACHE_SIZE-1)) is an idiom for offset into a page of pos*/ |
1259 |
/* (pos & (PAGE_CACHE_SIZE-1)) is an idiom for offset into a page of pos*/ |
1261 |
num_pages = !!((pos+count) & (PAGE_CACHE_SIZE - 1)) + /* round up partial |
1260 |
num_pages = !!((pos+count) & (PAGE_CACHE_SIZE - 1)) + /* round up partial |
Lines 1269-1275
Link Here
|
1269 |
/* If we were asked to write more data than we want to or if there |
1268 |
/* If we were asked to write more data than we want to or if there |
1270 |
is not that much space, then we shorten amount of data to write |
1269 |
is not that much space, then we shorten amount of data to write |
1271 |
for this iteration. */ |
1270 |
for this iteration. */ |
1272 |
num_pages = min_t(int, REISERFS_WRITE_PAGES_AT_A_TIME, reiserfs_can_fit_pages(inode->i_sb)); |
1271 |
num_pages = min_t(size_t, REISERFS_WRITE_PAGES_AT_A_TIME, reiserfs_can_fit_pages(inode->i_sb)); |
1273 |
/* Also we should not forget to set size in bytes accordingly */ |
1272 |
/* Also we should not forget to set size in bytes accordingly */ |
1274 |
write_bytes = (num_pages << PAGE_CACHE_SHIFT) - |
1273 |
write_bytes = (num_pages << PAGE_CACHE_SHIFT) - |
1275 |
(pos & (PAGE_CACHE_SIZE-1)); |
1274 |
(pos & (PAGE_CACHE_SIZE-1)); |
Lines 1295-1301
Link Here
|
1295 |
// But overwriting files on absolutelly full volumes would not |
1294 |
// But overwriting files on absolutelly full volumes would not |
1296 |
// be very efficient. Well, people are not supposed to fill |
1295 |
// be very efficient. Well, people are not supposed to fill |
1297 |
// 100% of disk space anyway. |
1296 |
// 100% of disk space anyway. |
1298 |
write_bytes = min_t(int, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1))); |
1297 |
write_bytes = min_t(size_t, count, inode->i_sb->s_blocksize - (pos & (inode->i_sb->s_blocksize - 1))); |
1299 |
num_pages = 1; |
1298 |
num_pages = 1; |
1300 |
// No blocks were claimed before, so do it now. |
1299 |
// No blocks were claimed before, so do it now. |
1301 |
reiserfs_claim_blocks_to_be_allocated(inode->i_sb, 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits)); |
1300 |
reiserfs_claim_blocks_to_be_allocated(inode->i_sb, 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits)); |