Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1427250ybg; Thu, 11 Jun 2020 09:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7pGdcphvLIIWV6qUWdpLGmp0udKuidXRe2PCq8LlkJMwKaYQk5Hhxf7yPVWab2zbMgKwc X-Received: by 2002:aa7:c254:: with SMTP id y20mr7722193edo.363.1591893174910; Thu, 11 Jun 2020 09:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591893174; cv=none; d=google.com; s=arc-20160816; b=L9J69dsUtWYDoizPh0HuI9ES0sdF8BXx/i5azuaptcQoHOPjVVt5xksiM42EakVE4y gHM7iOGRgDZ2mvEmvjStROX/ZkMiY5AS+EUBFMU9LOgPFtkqRSY13rbx9euhzV+spih3 sIYdgy7Ow4a71EyjouNC5NmNu5DkOdHXrn3RhNnCJ9z77gFmO4zdg5FEs493oStzdtFC dcXW+1CwHXu7OzwFUFIml17bYNffOHVboSc5s0hhW11QfjVeIISBDWvlinLzTHS7qien tAl73zgVqHgw7V7CGxAArmGMSHOhRl4003CDofcXdFpnpD+ZS2V6ghP0dHcFOXMY/GXJ fA4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WkwqhkBpyTGlJbizq83r0K/xb1w2pMHHyTxGcWlyq7M=; b=swLhFTygq71pr4ijFmAF9hOZvYblFdKIQrPzwPuNihDJyO409jtJMw4ajch0nvYdyo iOqC6N56kFFy7AqVwhDNjklPSCYenOM+KncpiJxRt0Mx2iMN0Jg70JkB+iwIRInmut31 Zaw/tYkymMJJZZ5O26vVZT5LGgeC8t4Xey9gLSHepAkhzVaLkhuR0lDszKvT74cirFQV 4a+zOXxtfcJgRWym3ObIXe0d/J/kkiaX7M5pofDY8B6mvCzdd41Y5AWTtDYeSy1MUROL LJuebATY8urEgCys7k4F64+wiNsTz56x1sqm7156lqZSe/VPrznBSEKmlUs3+SAYBcSr Autw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=loimR59E; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx2si2242394ejb.284.2020.06.11.09.32.30; Thu, 11 Jun 2020 09:32:54 -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=@kernel.org header.s=default header.b=loimR59E; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726507AbgFKQ1X (ORCPT + 99 others); Thu, 11 Jun 2020 12:27:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:35354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgFKQ1X (ORCPT ); Thu, 11 Jun 2020 12:27:23 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BA5D20792; Thu, 11 Jun 2020 16:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591892842; bh=7Vh2eMKAqsqarBEFvSteTBIrjnkfpF7p21JR7SHTWnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=loimR59ESifvGt9gJ/k3lNBbw2wz/KxaR8VRsFjmkzEE2gwVAEKMbUxbZxwC0zh8G IHOznBOCpQyR83dvEhg/xor9v5dDFIEziXXV9DM7mHWM//FUw1Y351w+jlomXLLxYm 1IB2eJK6fZTtEHbyFEQ79PmS6+uggD2KfvnuDJnA= Date: Thu, 11 Jun 2020 09:27:21 -0700 From: Eric Biggers To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH v2] f2fs: add F2FS_IOC_SEC_TRIM_FILE ioctl Message-ID: <20200611162721.GB1152@sol.localdomain> References: <20200611031652.200401-1-daeho43@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200611031652.200401-1-daeho43@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 11, 2020 at 12:16:52PM +0900, Daeho Jeong wrote: > + for (index = pg_start; index < pg_end;) { > + struct dnode_of_data dn; > + unsigned int end_offset; > + > + set_new_dnode(&dn, inode, NULL, NULL, 0); > + ret = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE); > + if (ret) > + goto out; > + > + end_offset = ADDRS_PER_PAGE(dn.node_page, inode); > + if (pg_end < end_offset + index) > + end_offset = pg_end - index; > + > + for (; dn.ofs_in_node < end_offset; > + dn.ofs_in_node++, index++) { > + struct block_device *cur_bdev; > + block_t blkaddr = f2fs_data_blkaddr(&dn); > + > + if (__is_valid_data_blkaddr(blkaddr)) { > + if (!f2fs_is_valid_blkaddr(F2FS_I_SB(inode), > + blkaddr, DATA_GENERIC_ENHANCE)) { > + ret = -EFSCORRUPTED; > + goto out; > + } > + } else > + continue; > + > + cur_bdev = f2fs_target_device(sbi, blkaddr, NULL); > + if (f2fs_is_multi_device(sbi)) { > + int i = f2fs_target_device_index(sbi, blkaddr); > + > + blkaddr -= FDEV(i).start_blk; > + } > + > + if (len) { > + if (prev_bdev == cur_bdev && > + blkaddr == prev_block + len) { > + len++; > + } else { > + ret = f2fs_secure_erase(prev_bdev, > + prev_block, len, flags); > + if (ret) > + goto out; > + > + len = 0; > + } > + } > + > + if (!len) { > + prev_bdev = cur_bdev; > + prev_block = blkaddr; > + len = 1; > + } > + } > + > + f2fs_put_dnode(&dn); > + } This loop processes the entire file, which may be very large. So it could take a very long time to execute. It should at least use the following to make the task killable and preemptible: if (fatal_signal_pending(current)) { err = -EINTR; goto out; } cond_resched(); Also, perhaps this ioctl should be made incremental, i.e. take in an (offset, length) like pwrite()? - Eric