Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp18082ybg; Thu, 11 Jun 2020 15:53:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiBakY6z9Ynqk7BoSSzKlIwhxmsbOFQV9BG7DV1gIpc1Z9mqBunEjALvNUehU13KLkxsU2 X-Received: by 2002:a05:6402:1814:: with SMTP id g20mr4407305edy.197.1591916028607; Thu, 11 Jun 2020 15:53:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591916028; cv=none; d=google.com; s=arc-20160816; b=IcrC30wXvnKCW+v7Qd8VsdhgWdYJPqnXAP51jr/KH6KM8Bgax9VjhDD80Y9zoQA6c1 6uE+5zBnnMvHdO7rgMkuw6NZ7ayK+vKLF23KExUWRJssa2jAgYEZ2yNuXqLZMIXh1Ica iYsa292KTBdCDYSX8PDTt7PHfhIvz/KuqRWADrRI1u4f3ikeeHavgdNyoUvNbMnMRYwG MYcPSr72+BnP1lt5KM4k3xkDfvQxUxfX2jsPikomJ6VlvwJRfdqWet8rZrQM1hmdf3eM Z86IxcE2VcxpdsA28bKKva9xdIn/kxj1n1suNEd2AeZgir0QLRUQ4scnKKO2OyJ9ryTa eGDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oZz4Kx4San+/C3xZHFDOh06j3X07sR49zOOViMY8pNY=; b=lUGH/3YFz+NzXKMnxrmVWKccZRVEPDJzVlqqmklmO8LCT1lP4SABStzFIUA6io8L3q 3T1M23wMRMhqnKcmAgilsv/m4GTMuSteRW+9J3rKJOPYWbXfM3ytABUaMr0fgrFdLDNn TeySL5Xo9U28358EqZlWhEC67jdIMnEEaNBQuR18nREOsFYKpoFeYXo+P4CJt9WEboV0 NqCO6YzCzRO4CHqlfEVRIta6ecD26dA2i1IlJpNdfYwpHHI/vJt+ueNSsPOhkJ58uqbI YbREPcBrMdnFH11bSFBVPNMkk8LwIAf1YlgvIK+4tu9dBKvuCLmmJ5pSTVr9FqXZGxEk GOdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qu6Ko60G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si2669888ejt.618.2020.06.11.15.53.25; Thu, 11 Jun 2020 15:53:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qu6Ko60G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726336AbgFKWtZ (ORCPT + 99 others); Thu, 11 Jun 2020 18:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726254AbgFKWtZ (ORCPT ); Thu, 11 Jun 2020 18:49:25 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60BEC08C5C1 for ; Thu, 11 Jun 2020 15:49:24 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id n23so8872785ljh.7 for ; Thu, 11 Jun 2020 15:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oZz4Kx4San+/C3xZHFDOh06j3X07sR49zOOViMY8pNY=; b=Qu6Ko60GtYwxe10GyVE0B3zOM0FY4oYGLYqqY9ggoIhFeONimPFed3eHImN+Nyw5et b3Sg0Uc0tND60uWSleH/sfpcz/gQowNVnvIjmzqHxdnpJI9BZbqe3/FBHDpcwbj9Hgch aXPMPWbA/tUAt2UsYEmwABgmb/tP/1UwJ6ODEhahCS4DqzluL8AwjH8NBkhrEdlZG1pK 5r9pKghrnu0nDCsScxsVBgD+x8P+QF2G7nif8yPMsG7EhsoZFqzMkQQzpcjPv0b+xINM dfI/U3F8KhB9nWWibplZggS+Bwgk8iP51DqotfpobqLvCqefK7nOEPVES65kIkT5woYN RX6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oZz4Kx4San+/C3xZHFDOh06j3X07sR49zOOViMY8pNY=; b=W7yV2PODnagnu/DXJG7BcLTGuHE3Sjej0doMTGu2TjIr8rBI+MSagLbYuaNSouBNkt odGSxqtaJ/kJW7dLziFmeKO34ozqCjDj5mL+2rEQYfq+/fuPeNxa/sVmIjQDnTi5sXy9 kvpSdqnBLClxZLhZNfhX6BJmFnqr7wvWxw+Vm13MSwaX7QxtQTvrHirsrsjMHi0BwJcv pYD0K/UDiL2e3YONb8rlWhgNZNegLkI0Gve72Nm7nCx74wuaHbbk8ogN6Vp8Ez/ow6yq 3UNXoJX5bfOizsCkejtquTTuxyQYiModjtYAONaGLFAWxkuRq0sE9NYQus6kMowMR/5d Haiw== X-Gm-Message-State: AOAM533gNV7L98mjDnE4Gai7DSRvbY0yTgZSwY9Y/3da0+kte8ok5ibO PVEAVDRqrQUNmjczO+huMGlxSVXLCE5ygy6fnTs= X-Received: by 2002:a2e:8107:: with SMTP id d7mr5712031ljg.363.1591915763067; Thu, 11 Jun 2020 15:49:23 -0700 (PDT) MIME-Version: 1.0 References: <20200611031652.200401-1-daeho43@gmail.com> <20200611162721.GB1152@sol.localdomain> In-Reply-To: <20200611162721.GB1152@sol.localdomain> From: Daeho Jeong Date: Fri, 12 Jun 2020 07:49:12 +0900 Message-ID: Subject: Re: [f2fs-dev] [PATCH v2] f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl To: Eric Biggers Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2020=EB=85=84 6=EC=9B=94 12=EC=9D=BC (=EA=B8=88) =EC=98=A4=EC=A0=84 1:27, E= ric Biggers =EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > On Thu, Jun 11, 2020 at 12:16:52PM +0900, Daeho Jeong wrote: > > + for (index =3D pg_start; index < pg_end;) { > > + struct dnode_of_data dn; > > + unsigned int end_offset; > > + > > + set_new_dnode(&dn, inode, NULL, NULL, 0); > > + ret =3D f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE); > > + if (ret) > > + goto out; > > + > > + end_offset =3D ADDRS_PER_PAGE(dn.node_page, inode); > > + if (pg_end < end_offset + index) > > + end_offset =3D pg_end - index; > > + > > + for (; dn.ofs_in_node < end_offset; > > + dn.ofs_in_node++, index++) { > > + struct block_device *cur_bdev; > > + block_t blkaddr =3D f2fs_data_blkaddr(&dn); > > + > > + if (__is_valid_data_blkaddr(blkaddr)) { > > + if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inod= e), > > + blkaddr, DATA_GENERIC_ENHANCE)) { > > + ret =3D -EFSCORRUPTED; > > + goto out; > > + } > > + } else > > + continue; > > + > > + cur_bdev =3D f2fs_target_device(sbi, blkaddr, NUL= L); > > + if (f2fs_is_multi_device(sbi)) { > > + int i =3D f2fs_target_device_index(sbi, b= lkaddr); > > + > > + blkaddr -=3D FDEV(i).start_blk; > > + } > > + > > + if (len) { > > + if (prev_bdev =3D=3D cur_bdev && > > + blkaddr =3D=3D prev_block + len) = { > > + len++; > > + } else { > > + ret =3D f2fs_secure_erase(prev_bd= ev, > > + prev_block, len, = flags); > > + if (ret) > > + goto out; > > + > > + len =3D 0; > > + } > > + } > > + > > + if (!len) { > > + prev_bdev =3D cur_bdev; > > + prev_block =3D blkaddr; > > + len =3D 1; > > + } > > + } > > + > > + f2fs_put_dnode(&dn); > > + } > > This loop processes the entire file, which may be very large. So it coul= d take > a very long time to execute. > > It should at least use the following to make the task killable and preemp= tible: > > if (fatal_signal_pending(current)) { > err =3D -EINTR; > goto out; > } > cond_resched(); > Good point! > Also, perhaps this ioctl should be made incremental, i.e. take in an > (offset, length) like pwrite()? > > - Eric Discard and Zeroing will be treated in a unit of block, which is 4KB in F2FS case. Do you really need the (offset, length) option here even if the unit is a 4KB block? I guess this option might make the user even inconvenienced to use this ioctl, because they have to bear 4KB alignment in mind.