All of lore.kernel.org
 help / color / mirror / Atom feed
* How to delete/rewrite a corrupted file in a read only snapshot?
@ 2024-02-06 19:12 Marc MERLIN
  2024-02-06 19:29 ` Holger Hoffstätte
  2024-02-07  5:07 ` Qu Wenruo
  0 siblings, 2 replies; 6+ messages in thread
From: Marc MERLIN @ 2024-02-06 19:12 UTC (permalink / raw)
  To: linux-btrfs

howdy,

I'm seeing this during a background check:
[374402.156920] BTRFS warning (device dm-18): checksum error at logical 4401320624128 on dev /dev/dm-18, physical 2939697954816, root 63534, inode 595460, offset 1506283520, length 4096, links 1 (path: nobck/file2)

this is in a read only btrfs send snapshot, so I can't just delete the
file or the snspshot (I have 20 historical ones all with the same broken
fine).

can I either
1) force delete it with some admin tool
2) even better force/overwrite it with the correct file from source?

Thanks,
Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
 
Home page: http://marc.merlins.org/                       | PGP 7F55D5F27AAF9D08

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to delete/rewrite a corrupted file in a read only snapshot?
  2024-02-06 19:12 How to delete/rewrite a corrupted file in a read only snapshot? Marc MERLIN
@ 2024-02-06 19:29 ` Holger Hoffstätte
  2024-02-07  3:56   ` Andrei Borzenkov
  2024-02-07  5:07 ` Qu Wenruo
  1 sibling, 1 reply; 6+ messages in thread
From: Holger Hoffstätte @ 2024-02-06 19:29 UTC (permalink / raw)
  To: Marc MERLIN, linux-btrfs

On 2024-02-06 20:12, Marc MERLIN wrote:
> howdy,
> 
> I'm seeing this during a background check:
> [374402.156920] BTRFS warning (device dm-18): checksum error at logical 4401320624128 on dev /dev/dm-18, physical 2939697954816, root 63534, inode 595460, offset 1506283520, length 4096, links 1 (path: nobck/file2)
> 
> this is in a read only btrfs send snapshot, so I can't just delete the
> file or the snspshot (I have 20 historical ones all with the same broken
> fine).
> 
> can I either
> 1) force delete it with some admin tool
> 2) even better force/overwrite it with the correct file from source?

You can flip subvolumes between read-only and read-write:

   $btrfs prop set yoursubvolume ro false

See "man btrfs-property" for details.

This should allow you to delete the broken file or replace it.

Good luck!
Holger

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to delete/rewrite a corrupted file in a read only snapshot?
  2024-02-06 19:29 ` Holger Hoffstätte
@ 2024-02-07  3:56   ` Andrei Borzenkov
  0 siblings, 0 replies; 6+ messages in thread
From: Andrei Borzenkov @ 2024-02-07  3:56 UTC (permalink / raw)
  To: Holger Hoffstätte, Marc MERLIN, linux-btrfs

On 06.02.2024 22:29, Holger Hoffstätte wrote:
> On 2024-02-06 20:12, Marc MERLIN wrote:
>> howdy,
>>
>> I'm seeing this during a background check:
>> [374402.156920] BTRFS warning (device dm-18): checksum error at logical 4401320624128 on dev /dev/dm-18, physical 2939697954816, root 63534, inode 595460, offset 1506283520, length 4096, links 1 (path: nobck/file2)
>>
>> this is in a read only btrfs send snapshot, so I can't just delete the
>> file or the snspshot (I have 20 historical ones all with the same broken
>> fine).
>>
>> can I either
>> 1) force delete it with some admin tool
>> 2) even better force/overwrite it with the correct file from source?
> 
> You can flip subvolumes between read-only and read-write:
> 

This will break replication chain.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to delete/rewrite a corrupted file in a read only snapshot?
  2024-02-06 19:12 How to delete/rewrite a corrupted file in a read only snapshot? Marc MERLIN
  2024-02-06 19:29 ` Holger Hoffstätte
@ 2024-02-07  5:07 ` Qu Wenruo
  2024-02-07 21:25   ` Marc MERLIN
  1 sibling, 1 reply; 6+ messages in thread
From: Qu Wenruo @ 2024-02-07  5:07 UTC (permalink / raw)
  To: Marc MERLIN, linux-btrfs



On 2024/2/7 05:42, Marc MERLIN wrote:
> howdy,
>
> I'm seeing this during a background check:
> [374402.156920] BTRFS warning (device dm-18): checksum error at logical 4401320624128 on dev /dev/dm-18, physical 2939697954816, root 63534, inode 595460, offset 1506283520, length 4096, links 1 (path: nobck/file2)
>
> this is in a read only btrfs send snapshot, so I can't just delete the
> file or the snspshot (I have 20 historical ones all with the same broken
> fine).
>
> can I either
> 1) force delete it with some admin tool

That would break any later incremental receive.

> 2) even better force/overwrite it with the correct file from source?

That's possible manually.

If you can get the correct content of that sector, you can manually
write it back to the location (all needed info is already in that line,
including where the device is, what's the physical offset, the size)

And later verify with scrub to make sure it's properly fixed.

Thanks,
Qu
>
> Thanks,
> Marc

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to delete/rewrite a corrupted file in a read only snapshot?
  2024-02-07  5:07 ` Qu Wenruo
@ 2024-02-07 21:25   ` Marc MERLIN
  2024-02-07 21:30     ` Qu Wenruo
  0 siblings, 1 reply; 6+ messages in thread
From: Marc MERLIN @ 2024-02-07 21:25 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Wed, Feb 07, 2024 at 03:37:04PM +1030, Qu Wenruo wrote:
> > can I either
> > 1) force delete it with some admin tool
> 
> That would break any later incremental receive.
> 
> > 2) even better force/overwrite it with the correct file from source?
> 
> That's possible manually.

If I change the snapshot to readwrite, and cat the good file into the
corrupted one 
cat good > /path/to/bad
will that work, or will that allocate new COW blocks and do weird things
that would break later brfs send/receive?

Thanks,
Marc
-- 
"A mouse is a device used to point at the xterm you want to type in" - A.S.R.
 
Home page: http://marc.merlins.org/                       | PGP 7F55D5F27AAF9D08

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How to delete/rewrite a corrupted file in a read only snapshot?
  2024-02-07 21:25   ` Marc MERLIN
@ 2024-02-07 21:30     ` Qu Wenruo
  0 siblings, 0 replies; 6+ messages in thread
From: Qu Wenruo @ 2024-02-07 21:30 UTC (permalink / raw)
  To: Marc MERLIN; +Cc: linux-btrfs



On 2024/2/8 07:55, Marc MERLIN wrote:
> On Wed, Feb 07, 2024 at 03:37:04PM +1030, Qu Wenruo wrote:
>>> can I either
>>> 1) force delete it with some admin tool
>>
>> That would break any later incremental receive.
>>
>>> 2) even better force/overwrite it with the correct file from source?
>>
>> That's possible manually.
>
> If I change the snapshot to readwrite, and cat the good file into the
> corrupted one
> cat good > /path/to/bad
> will that work, or will that allocate new COW blocks and do weird things
> that would break later brfs send/receive?

As long as you changed the snapshot to RW, it would break later
incremental receive IIRC, but I'm not 100% sure.

And for that cat, it would definitely lead to COW.

So, no, that would not fix the corrupted sector, you have to go the
dangerous way.

Thanks,
Qu

>
> Thanks,
> Marc

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-07 21:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 19:12 How to delete/rewrite a corrupted file in a read only snapshot? Marc MERLIN
2024-02-06 19:29 ` Holger Hoffstätte
2024-02-07  3:56   ` Andrei Borzenkov
2024-02-07  5:07 ` Qu Wenruo
2024-02-07 21:25   ` Marc MERLIN
2024-02-07 21:30     ` Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.