Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 42903
b: refs/heads/master
c: c557476
h: refs/heads/master
i:
  42901: c024fca
  42899: 2e70684
  42895: 2456ba3
v: v3
  • Loading branch information
Vladimir V. Saveliev authored and Linus Torvalds committed Dec 7, 2006
1 parent 9828f8d commit 188955e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 51 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 301827acbe49d0ba7ec9770803970893ac9ded97
refs/heads/master: c55747682e938c57a9a859d3b26f2c4c83cea011
54 changes: 4 additions & 50 deletions trunk/fs/reiserfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
we restart it. This will also free the path. */
if (journal_transaction_should_end
(th, th->t_blocks_allocated)) {
inode->i_size = cpu_key_k_offset(&key) +
(to_paste << inode->i_blkbits);
res =
restart_transaction(th, inode,
&path);
Expand Down Expand Up @@ -1310,56 +1312,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
count = MAX_NON_LFS - (unsigned long)*ppos;
}

if (file->f_flags & O_DIRECT) { // Direct IO needs treatment
ssize_t result, after_file_end = 0;
if ((*ppos + count >= inode->i_size)
|| (file->f_flags & O_APPEND)) {
/* If we are appending a file, we need to put this savelink in here.
If we will crash while doing direct io, finish_unfinished will
cut the garbage from the file end. */
reiserfs_write_lock(inode->i_sb);
err =
journal_begin(&th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT);
if (err) {
reiserfs_write_unlock(inode->i_sb);
return err;
}
reiserfs_update_inode_transaction(inode);
add_save_link(&th, inode, 1 /* Truncate */ );
after_file_end = 1;
err =
journal_end(&th, inode->i_sb,
JOURNAL_PER_BALANCE_CNT);
reiserfs_write_unlock(inode->i_sb);
if (err)
return err;
}
result = do_sync_write(file, buf, count, ppos);

if (after_file_end) { /* Now update i_size and remove the savelink */
struct reiserfs_transaction_handle th;
reiserfs_write_lock(inode->i_sb);
err = journal_begin(&th, inode->i_sb, 1);
if (err) {
reiserfs_write_unlock(inode->i_sb);
return err;
}
reiserfs_update_inode_transaction(inode);
mark_inode_dirty(inode);
err = journal_end(&th, inode->i_sb, 1);
if (err) {
reiserfs_write_unlock(inode->i_sb);
return err;
}
err = remove_save_link(inode, 1 /* truncate */ );
reiserfs_write_unlock(inode->i_sb);
if (err)
return err;
}

return result;
}
if (file->f_flags & O_DIRECT)
return do_sync_write(file, buf, count, ppos);

if (unlikely((ssize_t) count < 0))
return -EINVAL;
Expand Down

0 comments on commit 188955e

Please sign in to comment.