From patchwork Fri Mar 4 16:10:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 8505161 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D20499F7CA for ; Fri, 4 Mar 2016 16:11:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 72A092014A for ; Fri, 4 Mar 2016 16:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7EA3920145 for ; Fri, 4 Mar 2016 16:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759736AbcCDQLg (ORCPT ); Fri, 4 Mar 2016 11:11:36 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:15857 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759490AbcCDQLc (ORCPT ); Fri, 4 Mar 2016 11:11:32 -0500 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u24G9RX3031370; Fri, 4 Mar 2016 08:11:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=ID3mSZXt2jMA9yXQWxmxpS/VLgWHEbeO76daF+zvJ4k=; b=G1i2K6x/x4r6wCn8PqtdsuYdrKts7jp8j5rZGkPduUC51K9Kikad86A0w3XXi8wrJXGE qrLy976R/RN5tj0LNCOeme1jDsZl8IWuSYiJDg9umimfdRLK9rd8wxqfl4SbveGG+qR6 c5jsrl40sG7JoZn89cqqKi2dEdRsrHI4+wQ= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 21f6yj1f44-5 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Fri, 04 Mar 2016 08:11:26 -0800 Received: from localhost.localdomain (192.168.54.13) by mail.thefacebook.com (192.168.16.15) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 4 Mar 2016 08:11:01 -0800 From: Jens Axboe To: , CC: , , , Jens Axboe Subject: [PATCH 03/11] Add support for per-file/inode stream ID Date: Fri, 4 Mar 2016 09:10:45 -0700 Message-ID: <1457107853-8689-4-git-send-email-axboe@fb.com> X-Mailer: git-send-email 2.4.1.168.g1ea28e1 In-Reply-To: <1457107853-8689-1-git-send-email-axboe@fb.com> References: <1457107853-8689-1-git-send-email-axboe@fb.com> MIME-Version: 1.0 X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-03-04_07:, , signatures=0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Writing on flash devices can be much more efficient, if we can inform the device what kind of data can be grouped together. If the device is able to group data together with similar lifetimes, then it can be more efficient in garbage collection. This, in turn, leads to lower write amplification, which is a win on both device wear and performance. Signed-off-by: Jens Axboe --- fs/inode.c | 1 + fs/open.c | 1 + include/linux/fs.h | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/fs/inode.c b/fs/inode.c index 69b8b526c194..3e3652a04509 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -147,6 +147,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) inode->i_blocks = 0; inode->i_bytes = 0; inode->i_generation = 0; + inode->i_streamid = 0; inode->i_pipe = NULL; inode->i_bdev = NULL; inode->i_cdev = NULL; diff --git a/fs/open.c b/fs/open.c index 55bdc75e2172..38999d86fae0 100644 --- a/fs/open.c +++ b/fs/open.c @@ -749,6 +749,7 @@ static int do_dentry_open(struct file *f, f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); + f->f_streamid = 0; return 0; diff --git a/include/linux/fs.h b/include/linux/fs.h index ae681002100a..10599d231b53 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -660,6 +660,7 @@ struct inode { #ifdef CONFIG_IMA atomic_t i_readcount; /* struct files open RO */ #endif + unsigned int i_streamid; const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ struct file_lock_context *i_flctx; struct address_space i_data; @@ -681,6 +682,14 @@ struct inode { void *i_private; /* fs or device private pointer */ }; +static inline unsigned int inode_streamid(struct inode *inode) +{ + if (inode) + return inode->i_streamid; + + return 0; +} + static inline int inode_unhashed(struct inode *inode) { return hlist_unhashed(&inode->i_hash); @@ -877,6 +886,7 @@ struct file { * Must not be taken from IRQ context. */ spinlock_t f_lock; + unsigned int f_streamid; atomic_long_t f_count; unsigned int f_flags; fmode_t f_mode; @@ -908,6 +918,18 @@ struct file_handle { unsigned char f_handle[0]; }; +/* + * If the file doesn't have a stream ID set, return the inode stream ID + * in case that has been set. + */ +static inline unsigned int file_streamid(struct file *f) +{ + if (f->f_streamid) + return f->f_streamid; + + return inode_streamid(f->f_inode); +} + static inline struct file *get_file(struct file *f) { atomic_long_inc(&f->f_count);