linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: discard and data=writeback
       [not found] <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p1>
@ 2020-12-29  5:41 ` Daejun Park
  2020-12-29 13:42   ` Matteo Croce
       [not found]   ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p5>
  0 siblings, 2 replies; 5+ messages in thread
From: Daejun Park @ 2020-12-29  5:41 UTC (permalink / raw)
  To: mcroce, tytso; +Cc: linux-ext4

Hi,

> # dmesg |grep EXT4-fs |tail -1
> [ 1594.829833] EXT4-fs (nvme0n1p1): mounted filesystem with ordered
> data mode. Opts: data=ordered,discard
> # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> [1] 3032
> 
> real    0m1.328s
> user    0m0.063s
> sys     0m1.231s
> # === nvme0n1 ===
>   CPU  0:                    0 events,        0 KiB data
>   CPU  1:                    0 events,        0 KiB data
>   CPU  2:                    0 events,        0 KiB data
>   CPU  3:                 1461 events,       69 KiB data
>   CPU  4:                    1 events,        1 KiB data
>   CPU  5:                    0 events,        0 KiB data
>   CPU  6:                    0 events,        0 KiB data
>   CPU  7:                    0 events,        0 KiB data
>   Total:                  1462 events (dropped 0),       69 KiB data
> 
> 
> # dmesg |grep EXT4-fs |tail -1
> [ 1734.837651] EXT4-fs (nvme0n1p1): mounted filesystem with writeback
> data mode. Opts: data=writeback,discard
> # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> [1] 3069
> 
> real    1m30.273s
> user    0m0.139s
> sys     0m3.084s
> # === nvme0n1 ===
>   CPU  0:               133830 events,     6274 KiB data
>   CPU  1:                21878 events,     1026 KiB data
>   CPU  2:                46365 events,     2174 KiB data
>   CPU  3:                98116 events,     4600 KiB data
>   CPU  4:               290902 events,    13637 KiB data
>   CPU  5:                10926 events,      513 KiB data
>   CPU  6:                76861 events,     3603 KiB data
>   CPU  7:                17855 events,      837 KiB data
>   Total:                696733 events (dropped 0),    32660 KiB data
> 

In this result, there is few IO in ordered mode.

As I understand (please correct this if I am wrong), with writeback +
discard, ext4_issue_discard is called immediately at each rm command.
However, with ordered mode, ext4_issue_discard is called when end of
committing a transaction to pace with the corresponding transaction.
It means, they are not discarded yet.

Even with ordered mode, if sync is called after rm command,
ext4_issue_discard can be called due to transaction commit.
So, I think you will get similar results form writeback mode with sync
command.

Thanks,
Daejun

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

* Re: discard and data=writeback
  2020-12-29  5:41 ` discard and data=writeback Daejun Park
@ 2020-12-29 13:42   ` Matteo Croce
       [not found]   ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p5>
  1 sibling, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2020-12-29 13:42 UTC (permalink / raw)
  To: daejun7.park; +Cc: tytso, linux-ext4

On Tue, Dec 29, 2020 at 6:41 AM Daejun Park <daejun7.park@samsung.com> wrote:
>
> Hi,
>
> > # dmesg |grep EXT4-fs |tail -1
> > [ 1594.829833] EXT4-fs (nvme0n1p1): mounted filesystem with ordered
> > data mode. Opts: data=ordered,discard
> > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > [1] 3032
> >
> > real    0m1.328s
> > user    0m0.063s
> > sys     0m1.231s
> > # === nvme0n1 ===
> >   CPU  0:                    0 events,        0 KiB data
> >   CPU  1:                    0 events,        0 KiB data
> >   CPU  2:                    0 events,        0 KiB data
> >   CPU  3:                 1461 events,       69 KiB data
> >   CPU  4:                    1 events,        1 KiB data
> >   CPU  5:                    0 events,        0 KiB data
> >   CPU  6:                    0 events,        0 KiB data
> >   CPU  7:                    0 events,        0 KiB data
> >   Total:                  1462 events (dropped 0),       69 KiB data
> >
> >
> > # dmesg |grep EXT4-fs |tail -1
> > [ 1734.837651] EXT4-fs (nvme0n1p1): mounted filesystem with writeback
> > data mode. Opts: data=writeback,discard
> > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > [1] 3069
> >
> > real    1m30.273s
> > user    0m0.139s
> > sys     0m3.084s
> > # === nvme0n1 ===
> >   CPU  0:               133830 events,     6274 KiB data
> >   CPU  1:                21878 events,     1026 KiB data
> >   CPU  2:                46365 events,     2174 KiB data
> >   CPU  3:                98116 events,     4600 KiB data
> >   CPU  4:               290902 events,    13637 KiB data
> >   CPU  5:                10926 events,      513 KiB data
> >   CPU  6:                76861 events,     3603 KiB data
> >   CPU  7:                17855 events,      837 KiB data
> >   Total:                696733 events (dropped 0),    32660 KiB data
> >
>
> In this result, there is few IO in ordered mode.
>
> As I understand (please correct this if I am wrong), with writeback +
> discard, ext4_issue_discard is called immediately at each rm command.
> However, with ordered mode, ext4_issue_discard is called when end of
> committing a transaction to pace with the corresponding transaction.
> It means, they are not discarded yet.
>
> Even with ordered mode, if sync is called after rm command,
> ext4_issue_discard can be called due to transaction commit.
> So, I think you will get similar results form writeback mode with sync
> command.
>

Hi,

that's what I get with data=ordered if I issue a sync after the removal:

# time rm -rf /media/linux-5.10/ ; sync ; kill $!

real    0m1.569s
user    0m0.044s
sys     0m1.508s
#
 === nvme0n1 ===
 CPU  0:                10980 events,      515 KiB data
 CPU  1:                    0 events,        0 KiB data
 CPU  2:                    0 events,        0 KiB data
 CPU  3:                   26 events,        2 KiB data
 CPU  4:                 3601 events,      169 KiB data
 CPU  5:                    0 events,        0 KiB data
 CPU  6:                21786 events,     1022 KiB data
 CPU  7:                    0 events,        0 KiB data
 Total:                 36393 events (dropped 0),     1706 KiB data

Still way less transactions than writeback.

Cheers,
-- 
per aspera ad upstream

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

* RE: Re: discard and data=writeback
       [not found]   ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p5>
@ 2020-12-30  5:21     ` Daejun Park
  2020-12-30 15:16       ` Matteo Croce
       [not found]       ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p6>
  0 siblings, 2 replies; 5+ messages in thread
From: Daejun Park @ 2020-12-30  5:21 UTC (permalink / raw)
  To: Matteo Croce, Daejun Park; +Cc: tytso, linux-ext4

> Hi,
> >
> > > # dmesg |grep EXT4-fs |tail -1
> > > [ 1594.829833] EXT4-fs (nvme0n1p1): mounted filesystem with ordered
> > > data mode. Opts: data=ordered,discard
> > > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > > [1] 3032
> > >
> > > real    0m1.328s
> > > user    0m0.063s
> > > sys     0m1.231s
> > > # === nvme0n1 ===
> > >   CPU  0:                    0 events,        0 KiB data
> > >   CPU  1:                    0 events,        0 KiB data
> > >   CPU  2:                    0 events,        0 KiB data
> > >   CPU  3:                 1461 events,       69 KiB data
> > >   CPU  4:                    1 events,        1 KiB data
> > >   CPU  5:                    0 events,        0 KiB data
> > >   CPU  6:                    0 events,        0 KiB data
> > >   CPU  7:                    0 events,        0 KiB data
> > >   Total:                  1462 events (dropped 0),       69 KiB data
> > >
> > >
> > > # dmesg |grep EXT4-fs |tail -1
> > > [ 1734.837651] EXT4-fs (nvme0n1p1): mounted filesystem with writeback
> > > data mode. Opts: data=writeback,discard
> > > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > > [1] 3069
> > >
> > > real    1m30.273s
> > > user    0m0.139s
> > > sys     0m3.084s
> > > # === nvme0n1 ===
> > >   CPU  0:               133830 events,     6274 KiB data
> > >   CPU  1:                21878 events,     1026 KiB data
> > >   CPU  2:                46365 events,     2174 KiB data
> > >   CPU  3:                98116 events,     4600 KiB data
> > >   CPU  4:               290902 events,    13637 KiB data
> > >   CPU  5:                10926 events,      513 KiB data
> > >   CPU  6:                76861 events,     3603 KiB data
> > >   CPU  7:                17855 events,      837 KiB data
> > >   Total:                696733 events (dropped 0),    32660 KiB data
> > >
> >
> > In this result, there is few IO in ordered mode.
> >
> > As I understand (please correct this if I am wrong), with writeback +
> > discard, ext4_issue_discard is called immediately at each rm command.
> > However, with ordered mode, ext4_issue_discard is called when end of
> > committing a transaction to pace with the corresponding transaction.
> > It means, they are not discarded yet.
> >
> > Even with ordered mode, if sync is called after rm command,
> > ext4_issue_discard can be called due to transaction commit.
> > So, I think you will get similar results form writeback mode with sync
> > command.
> >
> 
> Hi,
> 
> that's what I get with data=ordered if I issue a sync after the removal:
> 
> # time rm -rf /media/linux-5.10/ ; sync ; kill $!
> 
> real    0m1.569s
> user    0m0.044s
> sys     0m1.508s
> #
>  === nvme0n1 ===
>  CPU  0:                10980 events,      515 KiB data
>  CPU  1:                    0 events,        0 KiB data
>  CPU  2:                    0 events,        0 KiB data
>  CPU  3:                   26 events,        2 KiB data
>  CPU  4:                 3601 events,      169 KiB data
>  CPU  5:                    0 events,        0 KiB data
>  CPU  6:                21786 events,     1022 KiB data
>  CPU  7:                    0 events,        0 KiB data
>  Total:                 36393 events (dropped 0),     1706 KiB data
> 
> Still way less transactions than writeback.
> 
The full trace you shared on this thread seems contains only on writeback
mode. In the trace, discards are issued by each deletion file by rm.

If you share the full trace on ordered mode, it will help we analyze the
results. It is expected that number of discards will lower than writeback
mode, because discards can be merged on ordered mode.

Thanks,
Daejun

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

* Re: Re: discard and data=writeback
  2020-12-30  5:21     ` Daejun Park
@ 2020-12-30 15:16       ` Matteo Croce
       [not found]       ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p6>
  1 sibling, 0 replies; 5+ messages in thread
From: Matteo Croce @ 2020-12-30 15:16 UTC (permalink / raw)
  To: daejun7.park; +Cc: tytso, linux-ext4

On Wed, Dec 30, 2020 at 6:21 AM Daejun Park <daejun7.park@samsung.com> wrote:
>
> > Hi,
> > >
> > > > # dmesg |grep EXT4-fs |tail -1
> > > > [ 1594.829833] EXT4-fs (nvme0n1p1): mounted filesystem with ordered
> > > > data mode. Opts: data=ordered,discard
> > > > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > > > [1] 3032
> > > >
> > > > real    0m1.328s
> > > > user    0m0.063s
> > > > sys     0m1.231s
> > > > # === nvme0n1 ===
> > > >   CPU  0:                    0 events,        0 KiB data
> > > >   CPU  1:                    0 events,        0 KiB data
> > > >   CPU  2:                    0 events,        0 KiB data
> > > >   CPU  3:                 1461 events,       69 KiB data
> > > >   CPU  4:                    1 events,        1 KiB data
> > > >   CPU  5:                    0 events,        0 KiB data
> > > >   CPU  6:                    0 events,        0 KiB data
> > > >   CPU  7:                    0 events,        0 KiB data
> > > >   Total:                  1462 events (dropped 0),       69 KiB data
> > > >
> > > >
> > > > # dmesg |grep EXT4-fs |tail -1
> > > > [ 1734.837651] EXT4-fs (nvme0n1p1): mounted filesystem with writeback
> > > > data mode. Opts: data=writeback,discard
> > > > # blktrace /dev/nvme0n1 & sleep 1 ; time rm -rf /media/linux-5.10/ ; kill $!
> > > > [1] 3069
> > > >
> > > > real    1m30.273s
> > > > user    0m0.139s
> > > > sys     0m3.084s
> > > > # === nvme0n1 ===
> > > >   CPU  0:               133830 events,     6274 KiB data
> > > >   CPU  1:                21878 events,     1026 KiB data
> > > >   CPU  2:                46365 events,     2174 KiB data
> > > >   CPU  3:                98116 events,     4600 KiB data
> > > >   CPU  4:               290902 events,    13637 KiB data
> > > >   CPU  5:                10926 events,      513 KiB data
> > > >   CPU  6:                76861 events,     3603 KiB data
> > > >   CPU  7:                17855 events,      837 KiB data
> > > >   Total:                696733 events (dropped 0),    32660 KiB data
> > > >
> > >
> > > In this result, there is few IO in ordered mode.
> > >
> > > As I understand (please correct this if I am wrong), with writeback +
> > > discard, ext4_issue_discard is called immediately at each rm command.
> > > However, with ordered mode, ext4_issue_discard is called when end of
> > > committing a transaction to pace with the corresponding transaction.
> > > It means, they are not discarded yet.
> > >
> > > Even with ordered mode, if sync is called after rm command,
> > > ext4_issue_discard can be called due to transaction commit.
> > > So, I think you will get similar results form writeback mode with sync
> > > command.
> > >
> >
> > Hi,
> >
> > that's what I get with data=ordered if I issue a sync after the removal:
> >
> > # time rm -rf /media/linux-5.10/ ; sync ; kill $!
> >
> > real    0m1.569s
> > user    0m0.044s
> > sys     0m1.508s
> > #
> >  === nvme0n1 ===
> >  CPU  0:                10980 events,      515 KiB data
> >  CPU  1:                    0 events,        0 KiB data
> >  CPU  2:                    0 events,        0 KiB data
> >  CPU  3:                   26 events,        2 KiB data
> >  CPU  4:                 3601 events,      169 KiB data
> >  CPU  5:                    0 events,        0 KiB data
> >  CPU  6:                21786 events,     1022 KiB data
> >  CPU  7:                    0 events,        0 KiB data
> >  Total:                 36393 events (dropped 0),     1706 KiB data
> >
> > Still way less transactions than writeback.
> >
> The full trace you shared on this thread seems contains only on writeback
> mode. In the trace, discards are issued by each deletion file by rm.
>
> If you share the full trace on ordered mode, it will help we analyze the
> results. It is expected that number of discards will lower than writeback
> mode, because discards can be merged on ordered mode.
>

Hi,

I did the same blktrace with data=ordered,discard
Find it here:

https://drive.google.com/file/d/1gqffP9WPCME3_81xlXAQCiDlTK-Gqv4_/view?usp=sharing

Thanks,
-- 
per aspera ad upstream

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

* RE: Re: Re: discard and data=writeback
       [not found]       ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p6>
@ 2020-12-31  1:32         ` Daejun Park
  0 siblings, 0 replies; 5+ messages in thread
From: Daejun Park @ 2020-12-31  1:32 UTC (permalink / raw)
  To: Matteo Croce, Daejun Park; +Cc: tytso, linux-ext4

Hi,

In the trace files, the amount of discard is almost the same in both modes.
(ordered: 1096MB / writeback: 1078MB) However, there is a big difference in
the average discard size per request. (ordered: 15.6KB / writeback: 34.2MB)
In ext4, when data is deleted, discard is immediately issued in writeback
mode. Therefore, the average size of discard commands is small and the
number of discard commands is large.
However, if it is not in the writeback mode, discard commands are issued by
JBD after merging them. Therefore, the average size of discard is large and
the number of discard commands is small.

In conclusion, since discard commands are not merged in the writeback mode,
many fragmented discard commands occur, so it affects the elapsed time of
many file deletion. And it is not abnormal behavior of ext4 file system.

Thanks,
Daejun

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

end of thread, other threads:[~2020-12-31  1:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p1>
2020-12-29  5:41 ` discard and data=writeback Daejun Park
2020-12-29 13:42   ` Matteo Croce
     [not found]   ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p5>
2020-12-30  5:21     ` Daejun Park
2020-12-30 15:16       ` Matteo Croce
     [not found]       ` <CGME20201229054143epcms2p15ae3cce43bb3c503adf94528f354ba78@epcms2p6>
2020-12-31  1:32         ` Daejun Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).