Remove filesize checks for sync I/O journal commit
PATCH 1/1 Remove filesize checks for sync I/O journal commit
Filesize is not a good indication that the file needs to be synced. An example where this breaks is:
1. Open the file in O_SYNC|O_RDWR
2. Read a small portion of the file (say 64 bytes)
3. Lseek to starting of the file
4. Write 64 bytes
If the node crashes, it is not written out to disk because this was not committed in the journal and the other node which reads the file after recovery reads stale data (even if the write on the other node was successful)
---
fs/ocfs2/file.c +1 -3
@@ -2381,9 +2381,7 @@ out_dio:if (ret <0 ) written = ret; -if (!ret && ((old_size !=i_size_read (inode)) || - (old_clusters !=OCFS2_I (inode)->ip_clusters) || - has_refcount)) { +if (!ret) { ret =jbd2_journal_force_commit (osb->journal->j_journal);if (ret <0 ) written = ret;
PATCH 1/1 Remove filesize checks for sync I/O journal commit
Quoted 17 lines · On Tue, 4 Nov 2014 09:52:22 -0600 Goldwyn Rodrigues <[email protected]> wrote:
Filesize is not a good indication that the file needs to be synced. An example where this breaks is:
1. Open the file in O_SYNC|O_RDWR
2. Read a small portion of the file (say 64 bytes)
3. Lseek to starting of the file
4. Write 64 bytesIf the node crashes, it is not written out to disk because this was not committed in the journal and the other node which reads the file after recovery reads stale data (even if the write on the other node was successful)
...
fs/ocfs2/file.c out_dio: · line 2387
Quoted 10 lines
fs/ocfs2/file.c +1
-3@@ -2381,9 +2381,7 @@ out_dio:if (ret <0 ) written = ret; -if (!ret && ((old_size !=i_size_read (inode)) || - (old_clusters !=OCFS2_I (inode)->ip_clusters) || - has_refcount)) { +if (!ret) { ret =jbd2_journal_force_commit (osb->journal->j_journal);if (ret <0 ) written = ret;
Can we have a signed-off-by for this, please?
PATCH 1/1 Remove filesize checks for sync I/O journal commit
Quoted 22 lines · Andrew Morton
Quoted 20 lines · On Tue, 4 Nov 2014 09:52:22 -0600 Goldwyn Rodrigues <[email protected]> wrote:
Filesize is not a good indication that the file needs to be synced. An example where this breaks is:
1. Open the file in O_SYNC|O_RDWR
2. Read a small portion of the file (say 64 bytes)
3. Lseek to starting of the file
4. Write 64 bytesIf the node crashes, it is not written out to disk because this was not committed in the journal and the other node which reads the file after recovery reads stale data (even if the write on the other node was successful)
...
fs/ocfs2/file.c +0
-0@@ -2381,9 +2381,7 @@ out_dio:if (ret <0 ) written = ret;
Quoted 10 lines
fs/ocfs2/file.c out_dio: · line 2387
Quoted 7 lines
fs/ocfs2/file.c +1
-3-if (!ret && ((old_size !=i_size_read (inode)) || - (old_clusters !=OCFS2_I (inode)->ip_clusters) || - has_refcount)) { +if (!ret) { ret =jbd2_journal_force_commit (osb->journal->j_journal);if (ret <0 ) written = ret;Can we have a signed-off-by for this, please?
Oops. Missed that.
Signature · 1 line
Goldwyn
PATCH 1/1 Remove filesize checks for sync I/O journal commit
In reply to Goldwyn RodriguesQuoted 11 lines · Goldwyn Rodrigues
Filesize is not a good indication that the file needs to be synced. An example where this breaks is:
1. Open the file in O_SYNC|O_RDWR
2. Read a small portion of the file (say 64 bytes)
3. Lseek to starting of the file
4. Write 64 bytesIf the node crashes, it is not written out to disk because this was not committed in the journal and the other node which reads the file after recovery reads stale data (even if the write on the other node was successful)
This patch looks good, thanks for sending it over.
--Mark
--
Mark Fasheh
PATCH 1/1 Remove filesize checks for sync I/O journal commit
In reply to Goldwyn RodriguesHi Goldwyn,
Quoted 7 lines · Goldwyn Rodrigues
Filesize is not a good indication that the file needs to be synced. An example where this breaks is:
1. Open the file in O_SYNC|O_RDWR
2. Read a small portion of the file (say 64 bytes)
3. Lseek to starting of the file
4. Write 64 bytes
Quoted 5 lines
If the node crashes, it is not written out to disk because this was not committed in the journal and the other node which reads the file after recovery reads stale data (even if the write on the other node was successful)
I have a question that if user open the file with O_SYNC, it will call filemap_fdatawait_range() after generic_perform_write() to wait until data reaches the disk, why another node may read the stale data?
Thanks,
Xuejiufei
Quoted 22 lines
---
fs/ocfs2/file.c +1
-3@@ -2381,9 +2381,7 @@ out_dio:if (ret <0 ) written = ret; -if (!ret && ((old_size !=i_size_read (inode)) || - (old_clusters !=OCFS2_I (inode)->ip_clusters) || - has_refcount)) { +if (!ret) { ret =jbd2_journal_force_commit (osb->journal->j_journal);if (ret <0 ) written = ret;_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel