Skip to contentSkip to conversation

NFS data corruption on congested network

DISCUSSION Jacek Tomaka 3 participants 6 messages Feb 22, 2024 – Feb 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,
I ran into an issue where the NFS file ends up being corrupted on disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

After some investigation we have reasons to believe that the change was introduced by the following commit:
https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

We write a number of files on a single thread. Each file is up to 4GB. Before closing we call fdatasync. Sometimes the file ends up being corrupted. The corruptions is in a form of a number ( more than 3k pages in one case) of zero filled pages. When this happens the file cannot be deleted from the client machine which created the file, even when the process which wrote the file completed successfully.

The machines have about 128GB of memory, i think and probably network that leaves to be desired.

My reproducer is currently tied up to our internal software, but i suspect setting the write_congested flag randomly should allow to reproduce the issue.

Regards.
Jacek Tomaka

#1 lore raw
Quoted 5 lines · Jacek Tomaka

Hello,
I ran into an issue where the NFS file ends up being corrupted on disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

After some investigation we have reasons to believe that the change was introduced by the following commit:
https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

Thanks for the report.
Can you try a change to your kernel?

fs/nfs/write.c +3 -1
index bb79d3a886ae..08a787147bd2 100644
@@ -668,8 +668,10 @@ static int nfs_writepage_locked(struct folio *folio,
 	int err;
 
 	if (wbc->sync_mode == WB_SYNC_NONE &&
-	    NFS_SERVER(inode)->write_congested)
+	    NFS_SERVER(inode)->write_congested) {
+		folio_redirty_for_writepage(wbc, folio);
 		return AOP_WRITEPAGE_ACTIVATE;
+	}
 
 	nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
 	nfs_pageio_init_write(&pgio, inode, 0, false,

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Thanks,
NeilBrown

Quoted 11 lines

We write a number of files on a single thread. Each file is up to 4GB. Before closing we call fdatasync. Sometimes the file ends up being corrupted. The corruptions is in a form of a number ( more than 3k pages in one case) of zero filled pages. When this happens the file cannot be deleted from the client machine which created the file, even when the process which wrote the file completed successfully.

The machines have about 128GB of memory, i think and probably network that leaves to be desired.

My reproducer is currently tied up to our internal software, but i suspect setting the write_congested flag randomly should allow to reproduce the issue.

Regards.
Jacek Tomaka

#2 lore raw
Quoted 16 lines · NeilBrown
Quoted 5 lines · Jacek Tomaka

Hello,
I ran into an issue where the NFS file ends up being corrupted on disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

After some investigation we have reasons to believe that the change was introduced by the following commit:
https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

Thanks for the report.
Can you try a change to your kernel?

fs/nfs/write.c +0 -0
index bb79d3a886ae..08a787147bd2 100644
@@ -668,8 +668,10 @@ static int nfs_writepage_locked(struct folio *folio,
 	int err;

fs/nfs/write.c static int nfs_writepage_locked(struct folio *folio, · line 677

Quoted 10 lines
fs/nfs/write.c +3 -1
 
 	if (wbc->sync_mode == WB_SYNC_NONE &&
-	    NFS_SERVER(inode)->write_congested)
+	    NFS_SERVER(inode)->write_congested) {
+		folio_redirty_for_writepage(wbc, folio);
 		return AOP_WRITEPAGE_ACTIVATE;
+	}
 
 	nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
 	nfs_pageio_init_write(&pgio, inode, 0, false,

Actually this is only needed before linux 6.8 as only nfs_writepage() can call nfs_writepage_locked() with sync_mode of WB_SYNC_NONE. So v5.18 through v6.7 might need fixing.

NeilBrown

Quoted 23 lines

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Thanks,
NeilBrown

Quoted 11 lines

We write a number of files on a single thread. Each file is up to 4GB. Before closing we call fdatasync. Sometimes the file ends up being corrupted. The corruptions is in a form of a number ( more than 3k pages in one case) of zero filled pages. When this happens the file cannot be deleted from the client machine which created the file, even when the process which wrote the file completed successfully.

The machines have about 128GB of memory, i think and probably network that leaves to be desired.

My reproducer is currently tied up to our internal software, but i suspect setting the write_congested flag randomly should allow to reproduce the issue.

Regards.
Jacek Tomaka

#3 lore raw
Quoted 26 lines · NeilBrown
Quoted 24 lines · NeilBrown
Quoted 5 lines · Jacek Tomaka

Hello,
I ran into an issue where the NFS file ends up being corrupted on disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

After some investigation we have reasons to believe that the change was introduced by the following commit:
https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

Thanks for the report.
Can you try a change to your kernel?

fs/nfs/write.c +3 -1
index bb79d3a886ae..08a787147bd2 100644
@@ -668,8 +668,10 @@ static int nfs_writepage_locked(struct folio *folio,
      int err;
 
      if (wbc->sync_mode == WB_SYNC_NONE &&
-         NFS_SERVER(inode)->write_congested)
+         NFS_SERVER(inode)->write_congested) {
+             folio_redirty_for_writepage(wbc, folio);
              return AOP_WRITEPAGE_ACTIVATE;
+     }
 
Quoted 6 lines

fs/nfs/write.c static int nfs_writepage_locked(struct folio *folio, · line 677

Quoted 2 lines
fs/nfs/write.c +0 -0
      nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
      nfs_pageio_init_write(&pgio, inode, 0, false,

Actually this is only needed before linux 6.8 as only nfs_writepage() can call nfs_writepage_locked() with sync_mode of WB_SYNC_NONE. So v5.18 through v6.7 might need fixing.

Please do not forget the Linux 6.6-stable branch!!

Ced

Signature · 3 lines
Cedric Blancher <[email protected]>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur
#4 lore raw
In reply to NeilBrown

Hi NeilBrown,

Quoted 2 lines

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Things are looking good. I have ran it on 15 machines for good couple of hours and i do not see the problem. Usually i would see it after 1-3 iterations but now they are reaching 20 iterations without the problem.

Thank you for the fix.
Regards.
Jacek Tomaka

Temat: Re: NFS data corruption on congested network
Data: 2024-02-26 0:19
Nadawca: "NeilBrown" &lt;[email protected]>
Adresat: "Jacek Tomaka" &lt;[email protected]>;
DW: [email protected]; [email protected]; [email protected];

Quoted 5 lines
Quoted 5 lines · NeilBrown
Quoted 2 lines · Jacek Tomaka

Hello,
I ran into an issue where the NFS file ends up being corrupted on

disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

After some investigation we have reasons to believe that the

change was introduced by the following commit:

Quoted 1 line
Quoted 1 line
Quoted 1 line

https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

Quoted 9 lines

fs/nfs/write.c static int nfs_writepage_locked(struct folio

Quoted 9 lines

Thanks for the report.
Can you try a change to your kernel?

fs/nfs/write.c +0 -0
index bb79d3a886ae..08a787147bd2 100644
@@ -668,8 +668,10 @@ static int nfs_writepage_locked(struct folio

*folio,

Quoted 9 lines
Quoted 9 lines
fs/nfs/write.c +3 -1
 	int err;
 
 	if (wbc->sync_mode == WB_SYNC_NONE &amp;&amp;
-	    NFS_SERVER(inode)->write_congested)
+	    NFS_SERVER(inode)->write_congested) {
+		folio_redirty_for_writepage(wbc, folio);
 		return AOP_WRITEPAGE_ACTIVATE;
+	}
 
Quoted 21 lines

fs/nfs/write.c static int nfs_writepage_locked(struct folio · line 677

Quoted 2 lines
fs/nfs/write.c +0 -0
 	nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
 	nfs_pageio_init_write(&amp;pgio, inode, 0, false,

Actually this is only needed before linux 6.8 as only nfs_writepage() can call nfs_writepage_locked() with sync_mode of WB_SYNC_NONE. So v5.18 through v6.7 might need fixing.

NeilBrown

Quoted 11 lines

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Thanks,
NeilBrown

Quoted 2 lines

We write a number of files on a single thread. Each file is up to

4GB. Before closing we call fdatasync. Sometimes the file ends up being corrupted. The corruptions is in a form of a number ( more than 3k pages in one case) of zero filled pages.

Quoted 1 line
Quoted 1 line
Quoted 1 line

When this happens the file cannot be deleted from the client

machine which created the file, even when the process which wrote the file completed successfully.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The machines have about 128GB of memory, i think and probably

network that leaves to be desired.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

My reproducer is currently tied up to our internal software, but i

suspect setting the write_congested flag randomly should allow to reproduce the issue.

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

Regards.
Jacek Tomaka

#5 lore raw
Quoted 8 lines · Jacek Tomaka

Hi NeilBrown,

Quoted 2 lines

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Things are looking good. I have ran it on 15 machines for good couple of hours and i do not see the problem. Usually i would see it after 1-3 iterations but now they are reaching 20 iterations without the problem.

Thank you for the fix.

Thanks for testing! I'll get the fix submitted.

NeilBrown

Quoted 85 lines

Regards.
Jacek Tomaka

Temat: Re: NFS data corruption on congested network
Data: 2024-02-26 0:19
Nadawca: "NeilBrown" &lt;[email protected]>
Adresat: "Jacek Tomaka" &lt;[email protected]>;
DW: [email protected]; [email protected]; [email protected];

Quoted 5 lines
Quoted 5 lines · NeilBrown
Quoted 2 lines · Jacek Tomaka

Hello,
I ran into an issue where the NFS file ends up being corrupted on

disk. We started noticing it on certain, quite old hardware after upgrading OS from Centos 6 to Rocky 9.2. We do see it on Rocky 9.3 but not on 9.1.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

After some investigation we have reasons to believe that the

change was introduced by the following commit:

Quoted 1 line
Quoted 1 line
Quoted 1 line

https://github.com/torvalds/linux/commit/6df25e58532be7a4cd6fb15bcd85805947402d91

Quoted 9 lines

fs/nfs/write.c static int nfs_writepage_locked(struct folio

Quoted 9 lines

Thanks for the report.
Can you try a change to your kernel?

fs/nfs/write.c +0 -0
index bb79d3a886ae..08a787147bd2 100644
@@ -668,8 +668,10 @@ static int nfs_writepage_locked(struct folio

*folio,

Quoted 9 lines
Quoted 9 lines
fs/nfs/write.c +3 -1
 	int err;
 
 	if (wbc->sync_mode == WB_SYNC_NONE &amp;&amp;
-	    NFS_SERVER(inode)->write_congested)
+	    NFS_SERVER(inode)->write_congested) {
+		folio_redirty_for_writepage(wbc, folio);
 		return AOP_WRITEPAGE_ACTIVATE;
+	}
 
Quoted 21 lines

fs/nfs/write.c static int nfs_writepage_locked(struct folio · line 677

Quoted 2 lines
fs/nfs/write.c +0 -0
 	nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
 	nfs_pageio_init_write(&amp;pgio, inode, 0, false,

Actually this is only needed before linux 6.8 as only nfs_writepage() can call nfs_writepage_locked() with sync_mode of WB_SYNC_NONE. So v5.18 through v6.7 might need fixing.

NeilBrown

Quoted 11 lines

though if your kernel is older than 6.3, that will be

         redirty_for_writepage(wbc, page);

Thanks,
NeilBrown

Quoted 2 lines

We write a number of files on a single thread. Each file is up to

4GB. Before closing we call fdatasync. Sometimes the file ends up being corrupted. The corruptions is in a form of a number ( more than 3k pages in one case) of zero filled pages.

Quoted 1 line
Quoted 1 line
Quoted 1 line

When this happens the file cannot be deleted from the client

machine which created the file, even when the process which wrote the file completed successfully.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

The machines have about 128GB of memory, i think and probably

network that leaves to be desired.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

My reproducer is currently tied up to our internal software, but i

suspect setting the write_congested flag randomly should allow to reproduce the issue.

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

Regards.
Jacek Tomaka