• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/fs/reiserfs/

Lines Matching refs:to

22 ** multiple writes and are small enough to have tails.
26 ** small enough to have a tail, and the tail is currently in an
29 ** We use reiserfs_truncate_file to pack the tail, since it already has
41 /* fast out for when nothing needs to be done */
59 * us to log any additional blocks (including quota blocks)
63 /* uh oh, we can't allow the inode to go away while there
64 * is still preallocation blocks pending. Try to join the
102 item(s) had to be converted, then it may have to be
152 /* I really do not want to play with memory shortage right now, so
153 to simplify the code, we are not going to write more than this much pages at
154 a time. This still should considerably improve performance compared to 4k
158 /* Allocates blocks for a file to fulfil write request.
164 to touch */
165 int write_bytes, /* amount of bytes to write */
170 need to allocate to
175 struct cpu_key key; // cpu key of item that we are going to deal with
176 struct item_head *ih; // pointer to item head that we are going to deal with
177 struct buffer_head *bh; // Buffer head that contains items that we are going to deal with
178 __le32 *item; // pointer to item we are going to deal with
179 INITIALIZE_PATH(path); // path to item, that we are going to deal with.
180 b_blocknr_t *allocated_blocks; // Pointer to a place where allocated blocknumbers would be stored.
183 int curr_block; // current block used to keep track of unmapped blocks.
188 unsigned int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1; /* last modified byte offset in last page */
189 __u64 hole_size; // amount of blocks for a file hole, if it needed to be created.
190 int modifying_this_item = 0; // Flag for items traversal code to keep track
195 "green-9004: tried to allocate zero blocks?");
210 /* First we compose a key to point at the writing position, we want to do
214 /* If we came here, it means we absolutely need to open a transaction,
215 since we need to allocate some blocks */
232 hint.path = &path; // Path, so that block allocator can determine packing locality or whatever it needs to determine.
234 hint.search_start = 0; // We have no hint on where to search free blocks for block allocator.
240 /* Call block allocator to allocate blocks */
279 // Too bad, I have not found any way to convert a given region from
280 // cpu format to little endian format
298 ih = get_ih(&path); // Get a pointer to last item head in path.
299 item = get_item(&path); // Get a pointer to last item in path
303 might need to append file with holes
305 // Since we are writing past the file's end, we need to find out if
306 // there is a hole that needs to be inserted before our writing
307 // position, and how many blocks it is going to cover (we need to
308 // populate pointers to file blocks representing the hole with zeros)
313 * if ih is stat data, its offset is 0 and we don't want to
314 * add 1 to pos in the hole_size calculation
329 int to_paste = min_t(__u64, hole_size, MAX_ITEM_LEN(inode->i_sb->s_blocksize) / UNFM_P_SIZE); // How much data to insert first time.
330 /* area filled with zeroes, to supply as list of zero blocknumbers
345 /* Ok, there is existing indirect item already. Need to append it */
418 /* Now we want to check if transaction is too full, and if it is
434 /* Well, need to recalculate path and stuff */
459 // we are going to overwrite, so there is nothing to scan through for holes.
472 /* Then set the key to look for a new indirect item (offset of old
473 item is added to old item length */
493 continue; // loop to check all kinds of conditions and so on.
498 /* Ok, a hole. Now we need to check if we already prepared this
499 block to be journaled */
504 // here to detect if fs changed under
507 int fs_gen; // We store fs generation here to find if someone
515 // Sigh, fs was changed under us, we need to look for new
546 if (modifying_this_item) { // We need to log last-accessed block, if it
552 // Oh, well need to append to indirect item, or to create indirect item
556 // position. We do not need to recalculate path as it should
557 // already point to correct place.
576 // Last found item was statdata. That means we need to create indirect item.
595 occured, we need to warn user and return error */
630 // go through all the pages/buffers and map the buffers to newly allocated
631 // blocks (so that system knows where to write these pages later).
650 /* if this buffer is before requested data to map, skip it */
652 if (i == num_pages - 1 && block_start >= to)
653 /* If this buffer is after requested data to map, abort
657 if (!buffer_mapped(bh)) { // Ok, unmapped buffer, need to map it
673 // Need to deal with transaction here.
684 // update any changes we made to blk count
714 /* This function will copy data from userspace to specified pages within
718 int write_bytes, /* Amount of bytes to write */
719 struct page **prepared_pages, /* pointer to
720 array to
723 const char __user * buf /* Pointer to user-supplied
733 size_t count = min_t(size_t, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
738 /* Copy data from userspace to the current page */
756 unsigned from, unsigned to)
787 if (block_end <= from || block_start >= to) {
813 * If this is a partial write which happened to make all buffers
824 because we might want to allocate block numbers in-between.
825 This function assumes that caller will adjust file size to correct value. */
827 size_t num_pages, /* Number of pages to write */
828 size_t write_bytes, /* number of bytes to write */
833 int retval = 0; // Return value we are going to return.
841 int count = min_t(int, PAGE_CACHE_SIZE - offset, write_bytes); // How much of bytes to write to this page
847 retval = status; // To not overcomplicate matters We are going to
849 // we only remember error status to report it on
859 * longer possible, reset "need to pack" flag */
873 // this sets the proper flags for O_SYNC to trigger a commit
897 * we have to unlock the pages after updating i_size, otherwise
909 /* Look if passed writing region is going to touch file's tail
910 (if it is present). And if it is, convert the tail to unformatted node */
911 static int reiserfs_check_for_tail_and_convert(struct inode *inode, /* inode to deal with */
913 int write_bytes /* amount of bytes to write */
927 to look for tails, simply return */
932 /* find the item containing the last byte to be written, or if
946 * items), so we need to unpack it. */
948 which will in turn call other stuff and finally will boil down to
968 Returns number of unallocated blocks that should be allocated to cover
973 size_t num_pages, /* number of pages to
975 size_t write_bytes, /* Amount of bytes to be
978 struct page **prepared_pages /* pointer to array
979 where to store
986 int to = ((pos + write_bytes - 1) & (PAGE_CACHE_SIZE - 1)) + 1;
997 // Page appeared to be not up
998 // to date. Note how we have
1006 struct cpu_key key; // cpu key of item that we are going to deal with
1007 struct item_head *ih = NULL; // pointer to item head that we are going to deal with
1008 struct buffer_head *itembuf = NULL; // Buffer head that contains items that we are going to deal with
1009 INITIALIZE_PATH(path); // path to item, that we are going to deal with.
1010 __le32 *item = NULL; // pointer to item we are going to deal with
1016 "called with zero number of pages to process");
1022 we'd start to deal with mapping buffers to blocks. */
1038 these pages are counted as needed to be allocated */
1050 ((PAGE_CACHE_SIZE - to) >> inode->i_blkbits);
1058 if (from != 0) /* First page needs to be partially zeroed */
1061 if (to != PAGE_CACHE_SIZE) /* Last page needs to be partially zeroed */
1062 zero_user_page(prepared_pages[num_pages-1], to,
1063 PAGE_CACHE_SIZE - to, KM_USER0);
1072 we need to allocate (calculated above) */
1073 /* Mask write position to start on blocksize, we do it out of the
1076 /* Set cpu key to the starting position in a file (on left block boundary) */
1094 /* if this buffer is before requested data to map, skip it */
1097 if (i == num_pages - 1 && block_start >= to) {
1098 /* If this buffer is after requested data to map, abort
1108 Probably it would be possible to move parts of this code
1117 blocks--; // Decrease the amount of blocks that need to be
1119 continue; // Go to the next buffer
1125 /* Try to find next item */
1148 at that position, map the buffer to this block */
1152 blocks--; // Decrease the amount of blocks that need to be
1181 /* if this buffer is before requested data to map, skip it */
1184 if (buffer_mapped(bh)) { /* If it is mapped, we need to
1185 issue READ request for it to
1214 if (block_start >= to)
1215 /* if this buffer is after requested data to map, skip it */
1217 if (block_end > to) { /* Aha, our partial buffer */
1218 if (buffer_mapped(bh)) { /* If it is mapped, we need to
1219 issue READ request for it to
1225 to, block_end - to, KM_USER0);
1232 /* Wait for read requests we made to happen, if necessary */
1252 generic_file_write() is only appropriate for filesystems that are not seeking to optimize performance and want
1262 * to reiserfs which allows for fewer tree traversals.
1268 All of these reasons for not using only generic file write were understood back when reiserfs was first miscoded to
1269 use it, but we were in a hurry to make code freeze, and so it couldn't be revised then. This new code should make
1275 static ssize_t reiserfs_file_write(struct file *file, /* the file we are going to write into */
1276 const char __user * buf, /* pointer to user supplied data
1278 size_t count, /* amount of bytes to write */
1279 loff_t * ppos /* pointer to position in file that we start writing at. Should be updated to
1283 size_t already_written = 0; // Number of bytes already written to the file.
1287 struct inode *inode = file->f_path.dentry->d_inode; // Inode of the file that we are writing to.
1294 /* If a filesystem is converted from 3.5 to 3.6, we'll have v3.5 items
1298 * oblivious to the different limitations between old and new items.
1324 /* Check if we can write to specified region of file, file
1344 /* If we are going to write past the file's packed tail or if we are going
1345 to overwrite part of the tail, we need that tail to be converted into
1354 size_t num_pages; /* amount of pages we are going to write this iteration */
1355 size_t write_bytes; /* amount of bytes to write during this iteration */
1356 size_t blocks_to_allocate; /* how much blocks we need to allocate for this iteration */
1363 /* convert size to amount of
1368 /* If we were asked to write more data than we want to or if there
1369 is not that much space, then we shorten amount of data to write
1374 /* Also we should not forget to set size in bytes accordingly */
1379 to substract the offset
1384 /* reserve the blocks to be allocated later, so that later on
1385 we still have the space to write the blocks to */
1400 // let's set write size to be equal or less than blocksize.
1403 // be very efficient. Well, people are not supposed to fill
1445 if (blocks_to_allocate > 0) { /*We only allocate blocks if we need to */
1455 /* well, we have allocated the blocks, so it is time to free
1465 and probably we would do that just to get rid of garbage in files after a
1468 /* Copy data from user-supplied buffer to file's pages */
1478 /* Send the pages to disk and unlock them. */