aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2005-01-13 11:03:38 -0500
committerAnton Altaparmakov <aia21@cantab.net>2005-05-05 05:48:11 -0400
commitf40661be038ce6ed9ef6a8b80307a9153bd95769 (patch)
tree61c9c81643c96ffa7cdb186b10e5e2f141493b56 /fs
parent946929d813a3bde095678526dd037ab9ac6efe35 (diff)
NTFS: Optimise/reorganise some error handling code in fs/ntfs/aops.c.
Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/ntfs/aops.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 92215228eeab..812d53e93354 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -1392,14 +1392,11 @@ static int ntfs_writepage(struct page *page, struct writeback_control *wbc)
1392 1392
1393 attr_len = le32_to_cpu(ctx->attr->data.resident.value_length); 1393 attr_len = le32_to_cpu(ctx->attr->data.resident.value_length);
1394 i_size = i_size_read(vi); 1394 i_size = i_size_read(vi);
1395 kaddr = kmap_atomic(page, KM_USER0);
1396 if (unlikely(attr_len > i_size)) { 1395 if (unlikely(attr_len > i_size)) {
1397 /* Zero out of bounds area in the mft record. */
1398 memset((u8*)ctx->attr + le16_to_cpu(
1399 ctx->attr->data.resident.value_offset) +
1400 i_size, 0, attr_len - i_size);
1401 attr_len = i_size; 1396 attr_len = i_size;
1397 ctx->attr->data.resident.value_length = cpu_to_le32(attr_len);
1402 } 1398 }
1399 kaddr = kmap_atomic(page, KM_USER0);
1403 /* Copy the data from the page to the mft record. */ 1400 /* Copy the data from the page to the mft record. */
1404 memcpy((u8*)ctx->attr + 1401 memcpy((u8*)ctx->attr +
1405 le16_to_cpu(ctx->attr->data.resident.value_offset), 1402 le16_to_cpu(ctx->attr->data.resident.value_offset),
@@ -1831,7 +1828,7 @@ static int ntfs_prepare_write(struct file *file, struct page *page,
1831 unsigned from, unsigned to) 1828 unsigned from, unsigned to)
1832{ 1829{
1833 s64 new_size; 1830 s64 new_size;
1834 unsigned long flags; 1831 loff_t i_size;
1835 struct inode *vi = page->mapping->host; 1832 struct inode *vi = page->mapping->host;
1836 ntfs_inode *base_ni = NULL, *ni = NTFS_I(vi); 1833 ntfs_inode *base_ni = NULL, *ni = NTFS_I(vi);
1837 ntfs_volume *vol = ni->vol; 1834 ntfs_volume *vol = ni->vol;
@@ -1934,13 +1931,11 @@ static int ntfs_prepare_write(struct file *file, struct page *page,
1934 /* The total length of the attribute value. */ 1931 /* The total length of the attribute value. */
1935 attr_len = le32_to_cpu(a->data.resident.value_length); 1932 attr_len = le32_to_cpu(a->data.resident.value_length);
1936 /* Fix an eventual previous failure of ntfs_commit_write(). */ 1933 /* Fix an eventual previous failure of ntfs_commit_write(). */
1937 read_lock_irqsave(&ni->size_lock, flags); 1934 i_size = i_size_read(vi);
1938 if (unlikely(ni->initialized_size < attr_len)) { 1935 if (unlikely(attr_len > i_size)) {
1939 attr_len = ni->initialized_size; 1936 attr_len = i_size;
1940 a->data.resident.value_length = cpu_to_le32(attr_len); 1937 a->data.resident.value_length = cpu_to_le32(attr_len);
1941 BUG_ON(attr_len < i_size_read(vi));
1942 } 1938 }
1943 read_unlock_irqrestore(&ni->size_lock, flags);
1944 /* If we do not need to resize the attribute allocation we are done. */ 1939 /* If we do not need to resize the attribute allocation we are done. */
1945 if (new_size <= attr_len) 1940 if (new_size <= attr_len)
1946 goto done_unm; 1941 goto done_unm;