From patchwork Thu Jun 15 16:42:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9789267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3ED3160384 for ; Thu, 15 Jun 2017 16:42:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 318B128542 for ; Thu, 15 Jun 2017 16:42:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 268E9286B5; Thu, 15 Jun 2017 16:42:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE4C4284F5 for ; Thu, 15 Jun 2017 16:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751898AbdFOQmW (ORCPT ); Thu, 15 Jun 2017 12:42:22 -0400 Received: from mail-io0-f173.google.com ([209.85.223.173]:36030 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbdFOQmV (ORCPT ); Thu, 15 Jun 2017 12:42:21 -0400 Received: by mail-io0-f173.google.com with SMTP id y77so15428117ioe.3 for ; Thu, 15 Jun 2017 09:42:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7SO+E5wnKn4dSpOgYUTS5EtRq7MzU5KjPhnEJXljYdU=; b=Te5qvXEEsBaX7X/f6GQNs3iniTSRuf12HmKHe6w/L4iebf5lFhQbI+bWY9h7olwNMO RVDFN6UDWJSDOf6Hq35qfY3sVRRTTjg4VnPaqf4R+uo77/u7hErtt/jaHtdQJO+3px7n DFABWrEXH2ogZlUc+iiR4PylQh1kj19G5x9KUW6djR9SxV2yD3cWibJfhvrSpDgO2RN/ ZZZRVcEVLmxcGNVl0nCsxRqgJoYj+PheSumuGgHLeaAusyVM0XCbgI4I6MOfhtco2hsd SNZXz8oVWelxfoqxrOixzt+p49M0fLdbsY4ingg5mcr+rto7xzQ8DoTFrLuEqY7Yc77x +xkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7SO+E5wnKn4dSpOgYUTS5EtRq7MzU5KjPhnEJXljYdU=; b=OjhJKUeckU1b5mbPYWOByCvDT+8Nkw0xLhXpaCU4RHlTubdU04MLdiTkldPkRz85AG HsBRYIB8B+rNsjE5HZw6u9sDqhDghxnWFWxwH4ENXD7HaSmLlTnpTmhwCrw7PEGftImv K5rGpSmlmdXXMX1aF9R8gh818LGldjBYCkvdkSRWUP2wIdm7DVeQJN8sbHFTiXv1d3Vq eJ86K+5DymHmj8gEtuOqQHd3CvGCbFtdXlv1h1RQVr5IjuFqp4jfeMsvFHDXTs5Jsid3 AStAnq2clCufwlKwepoId1E9Picmp2XPYfWmguKvkG22JqnuTOXPH1FRgcJFWtZE+RMK J/xA== X-Gm-Message-State: AKS2vOz0WfCoBc+PRst8jbkrqGNR9bjhKUrj5x2fvNM9ESoBuh1WULr3 xUFw2Akvvsafn1k+ikasQQ== X-Received: by 10.107.169.17 with SMTP id s17mr6766095ioe.1.1497544940512; Thu, 15 Jun 2017 09:42:20 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id 97sm313476iot.25.2017.06.15.09.42.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Jun 2017 09:42:19 -0700 (PDT) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org Cc: adilger@dilger.ca, hch@infradead.org, martin.petersen@oracle.com, Jens Axboe Subject: [PATCH 05/12] fs: add fcntl() interface for setting/getting write life time hints Date: Thu, 15 Jun 2017 10:42:03 -0600 Message-Id: <1497544930-19174-6-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497544930-19174-1-git-send-email-axboe@kernel.dk> References: <1497544930-19174-1-git-send-email-axboe@kernel.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have a pwritev2(2) interface based on passing in flags. Add an fcntl interface for querying these flags, and also for setting them as well: F_GET_WRITE_LIFE Returns one of the valid type of write hints, like WRITE_HINT_MEDIUM. F_SET_WRITE_LIFE Pass in a WRITE_HINT_* type to set the write life time hint for this file/inode. Returns 0 on succes, -1 otherwise. Signed-off-by: Jens Axboe --- fs/fcntl.c | 38 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/fcntl.h | 6 ++++++ 2 files changed, 44 insertions(+) diff --git a/fs/fcntl.c b/fs/fcntl.c index f4e7267d117f..f89fef847f73 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -243,6 +243,40 @@ static int f_getowner_uids(struct file *filp, unsigned long arg) } #endif +long fcntl_write_life(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct inode *inode = file_inode(file); + long ret; + + switch (cmd) { + case F_GET_WRITE_LIFE: + ret = mask_to_write_hint(inode->i_flags, S_WRITE_LIFE_SHIFT); + break; + case F_SET_WRITE_LIFE: { + enum write_hint hint = arg; + + switch (hint) { + case WRITE_HINT_NONE: + case WRITE_HINT_SHORT: + case WRITE_HINT_MEDIUM: + case WRITE_HINT_LONG: + case WRITE_HINT_EXTREME: + inode_set_write_hint(inode, hint); + ret = 0; + break; + default: + ret = -EINVAL; + } + break; + } + default: + ret = -EINVAL; + break; + } + + return ret; +} + static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, struct file *filp) { @@ -337,6 +371,10 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, case F_GET_SEALS: err = shmem_fcntl(filp, cmd, arg); break; + case F_GET_WRITE_LIFE: + case F_SET_WRITE_LIFE: + err = fcntl_write_life(filp, cmd, arg); + break; default: break; } diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 813afd6eee71..1c5b2a95e9c9 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -43,6 +43,12 @@ /* (1U << 31) is reserved for signed error codes */ /* + * Set/Get write life time hints + */ +#define F_GET_WRITE_LIFE (F_LINUX_SPECIFIC_BASE + 11) +#define F_SET_WRITE_LIFE (F_LINUX_SPECIFIC_BASE + 20) + +/* * Types of directory notifications that may be requested. */ #define DN_ACCESS 0x00000001 /* File accessed */