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: 9792329 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 A4E9460231 for ; Fri, 16 Jun 2017 17:25:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89E942861D for ; Fri, 16 Jun 2017 17:25:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D27E28111; Fri, 16 Jun 2017 17:25:18 +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=unavailable 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 33ABD205AD for ; Fri, 16 Jun 2017 17:25:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750893AbdFPRY4 (ORCPT ); Fri, 16 Jun 2017 13:24:56 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:38173 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752063AbdFPRYy (ORCPT ); Fri, 16 Jun 2017 13:24:54 -0400 Received: by mail-it0-f53.google.com with SMTP id b205so16767718itg.1 for ; Fri, 16 Jun 2017 10:24:54 -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=INMwzrUfcjwhSJGE9WtV9fAeB++m0SnHCA7CASb1v6T3JQpjlSYxdrsD42yFKVv413 NCUIGzC7ABfwjxtglM+0hRASC1U7U6Kumfoh+fLBf7FYox9hocBHfvCzsSZB47z7EbpR 3zwIa70NCDtv11mlLMquj2JTDAtGmVpSu5UFVxdu3mwH0QZE4Rg6p4DEfzcLnOCDQL5j gsXKj7M1WyVsMLXPeGsMMM+hc4E/lWdL6FH70LuqOqtYqWhURb3FURj7ENIypHElqy4q ep4eqAhgwCE0vlvAxgYgHjtkOoQbJknrQv7/RWxtrboKlgvwj7xQkXRJHy/44tff6+Q/ T0sA== X-Gm-Message-State: AKS2vOwlGvSBAJ3I6mKtw1s0R18zf/uvLo/YfUGX6rWHWTfq7m1qgeaW GyBI9e6RdvByxrH+DL6iqQ== 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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 */