linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Mikhail Novosyolov via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>,
	Daeho Jeong <daehojeong@google.com>
Subject: Re: [f2fs-dev] Using secure erase in f2fs
Date: Wed, 2 Dec 2020 22:23:13 +0300	[thread overview]
Message-ID: <371efcfc-581b-2dcf-c2d7-ca7801fdb273@rosalinux.ru> (raw)
In-Reply-To: <6ab5fbf4-5c78-8edc-14f0-f280a330d23d@rosalinux.ru>

02.12.2020 21:24, Mikhail Novosyolov пишет:
> Hello, f2fs developers!
>
> I saw commit 9af846486d781a63 "f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl" in Linux kernel
> https://github.com/torvalds/linux/commit/9af846486d781a63de025a5f502c515268e48790#
>
> I saw usage of it in Android only
> https://android.googlesource.com/platform/system/vold/+/master/secdiscard.cpp
>
> Do I understand correctly that userspace code decides himself where the region to erase starts and when to call that ioctl?
>
> I am interested in it to implement realtime secure erase - overwriting files with zeros or random data (I am not interestied in sending a discard/trim command) - when files are deleted or are removed completely.
> This code seems to be a good solution of this problem, but the problem is that kernel cannot trigger it by itself.
What if do something like this?

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 7d8578401267..1e72ac27bfdf 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1166,6 +1166,10 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
                     SECTOR_FROM_BLOCK(start),
                     SECTOR_FROM_BLOCK(len),
                     GFP_NOFS, 0, &bio);
+        __blkdev_issue_write_zeroes(bdev,
+                    SECTOR_FROM_BLOCK(start),
+                    SECTOR_FROM_BLOCK(len),
+                    GFP_NOFS, 0, &bio);
 submit:
         if (err) {
             spin_lock_irqsave(&dc->lock, flags);

after of before __blkdev_issue_discard()?

Is it safe to fill the region which is being discarded with zeroes?

Will it work and will it fit with background housekeeping and discard queue?

>
> I think it should be possible to call this from another part of f2fs when a file is being edited or unlinked, but I am not sure from where exactly.
>
> F2FS has background housekeeping, it would be nice if it could issue secure trim in the background.
>
> Also, I am not sure that it will work with symlinks correctly, for example.
>
> Please give a direction.
>


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2020-12-02 19:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 18:24 [f2fs-dev] Using secure erase in f2fs Mikhail Novosyolov via Linux-f2fs-devel
2020-12-02 19:23 ` Mikhail Novosyolov via Linux-f2fs-devel [this message]
2020-12-02 23:41   ` Daeho Jeong
2020-12-03  8:25     ` Mikhail Novosyolov via Linux-f2fs-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=371efcfc-581b-2dcf-c2d7-ca7801fdb273@rosalinux.ru \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=daehojeong@google.com \
    --cc=m.novosyolov@rosalinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).