From patchwork Fri Jun 16 17:24:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9792305 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 7E8EC603B5 for ; Fri, 16 Jun 2017 17:25:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61A062029B for ; Fri, 16 Jun 2017 17:25:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55547200E7; Fri, 16 Jun 2017 17:25:01 +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 8851A200E7 for ; Fri, 16 Jun 2017 17:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133AbdFPRY4 (ORCPT ); Fri, 16 Jun 2017 13:24:56 -0400 Received: from mail-it0-f51.google.com ([209.85.214.51]:37102 "EHLO mail-it0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750893AbdFPRYy (ORCPT ); Fri, 16 Jun 2017 13:24:54 -0400 Received: by mail-it0-f51.google.com with SMTP id m47so31071229iti.0 for ; Fri, 16 Jun 2017 10:24:53 -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=u647X2F5ufuGbOaMIoEm+YDoaVOiixm6+6p5geFsrPI=; b=XXhiUzMprzLe51Xj50n3a4t9II0j94voC5drQuOrvazK/ovIfE4DuDunqEGANAVcZA +khiP0ahTZAEIs5gH6H+/VoOy4zLsW5XGKd+k6pIvYI+4NiPrGrUKCInEA0Sgo5xgmBy B5pBJT05nQOXB1+5IilDJVW7iaHTsqTZYt/KQxYorG0h9s8TuNfcRLhYQwRJD7hv9kKC hp4IbpRhyhSZGrPuLeOFu8jIox+d9sucsf9RE12TEgR3IoPmMGMPE8Xl4fBTy3fBJceC 9M1CG1Yd8U2vTQusrfH7V0yB9enfXPJnc31DtuJqKUovZ4jEiM3AzvdvzRGnpPRbMksY oMTg== 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=u647X2F5ufuGbOaMIoEm+YDoaVOiixm6+6p5geFsrPI=; b=PrfKS643jsUnWtpF6uy83FYwmnZZVlU7YGU7j9jiPna6bkP7e6J9Kw8TfQUqoSsafD 0ZJRhXkmAd3uhIU6BtF8esfb6hf4aJlCzVx6avcB7lY3hLNcOzLqJCYO2SEM4o56uxRa o9OgwiMR8iRTzgh9cdID2oM+lBl6SbFax0wEmE/rONU2ydoU/iWDDd+bog7PGF+wGN6F xWXhYY2EfBCVJ7n4ifSNsY1f6Z8oO7Kn8tp/uTPrjQ27+yK5Rxpq7fOtm6SWdKu5Up3r MZ1DSjEnuMgwlBi/jF9NuQdo4g5V/OcnO2N/M39R4cOJQruEqDTmqErDye6w9kdmTFBa 1Vyw== X-Gm-Message-State: AKS2vOxzIRy+LOeo2IGWI9TNfQU6pecFN475Nk1tHLluImoaT2szfjMQ Woo2Pqc48+FqIugx X-Received: by 10.36.89.137 with SMTP id p131mr11840972itb.12.1497633893000; Fri, 16 Jun 2017 10:24:53 -0700 (PDT) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id e31sm1661101ioi.51.2017.06.16.10.24.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 10:24:52 -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/11] fs: add fcntl() interface for setting/getting write life time hints Date: Fri, 16 Jun 2017 11:24:37 -0600 Message-Id: <1497633883-21230-6-git-send-email-axboe@kernel.dk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497633883-21230-1-git-send-email-axboe@kernel.dk> References: <1497633883-21230-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_RW_HINT Returns the read/write hint set. Right now it will be one of the WRITE_LIFE_* values. F_SET_RW_HINT Pass in rw_hint type to set the read/write hint. Only WRITE_LIFE_* hints are currently supported. 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..417ce336c875 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_rw_hint(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct inode *inode = file_inode(file); + long ret; + + switch (cmd) { + case F_GET_RW_HINT: + ret = mask_to_write_hint(inode->i_flags, S_WRITE_LIFE_SHIFT); + break; + case F_SET_RW_HINT: { + enum rw_hint hint = arg; + + switch (hint) { + case WRITE_LIFE_NONE: + case WRITE_LIFE_SHORT: + case WRITE_LIFE_MEDIUM: + case WRITE_LIFE_LONG: + case WRITE_LIFE_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_RW_HINT: + case F_SET_RW_HINT: + err = fcntl_rw_hint(filp, cmd, arg); + break; default: break; } diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 813afd6eee71..bd24c9b48bd0 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_RW_HINT (F_LINUX_SPECIFIC_BASE + 11) +#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 20) + +/* * Types of directory notifications that may be requested. */ #define DN_ACCESS 0x00000001 /* File accessed */