From: Jens Axboe <axboe@fb.com>
To: <linux-fsdevel@vger.kernel.org>, <linux-block@vger.kernel.org>
Cc: <calvinowens@fb.com>, <hch@lst.de>, <adilger@dilger.ca>,
Jens Axboe <axboe@fb.com>
Subject: [PATCH 03/11] Add support for per-file/inode stream ID
Date: Fri, 4 Mar 2016 09:10:45 -0700 [thread overview]
Message-ID: <1457107853-8689-4-git-send-email-axboe@fb.com> (raw)
In-Reply-To: <1457107853-8689-1-git-send-email-axboe@fb.com>
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 <axboe@fb.com>
---
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);
--
2.4.1.168.g1ea28e1
next prev parent reply other threads:[~2016-03-04 16:11 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 16:10 [PATCH 0/11] Update version of write stream ID patchset Jens Axboe
2016-03-04 16:10 ` [PATCH 01/11] idr: make ida_simple_remove() return an error Jens Axboe
2016-03-04 16:10 ` [PATCH 02/11] block: add support for carrying a stream ID in a bio Jens Axboe
2016-03-04 16:10 ` Jens Axboe [this message]
[not found] ` <CAJVOszBXU-qQENcOGG8pWeARwoWL2G3gNJ0H2uNPjXkiVa8S+Q@mail.gmail.com>
2016-03-04 20:35 ` [PATCH 03/11] Add support for per-file/inode stream ID Jens Axboe
2016-03-04 16:10 ` [PATCH 04/11] Add system call for setting inode/file write " Jens Axboe
2016-03-04 16:10 ` [PATCH 05/11] wire up system call for x86/x86-64 Jens Axboe
2016-03-04 16:10 ` [PATCH 06/11] Add support for bdi tracking of stream ID Jens Axboe
2016-03-04 16:10 ` [PATCH 07/11] direct-io: add support for write stream IDs Jens Axboe
2016-03-04 16:10 ` [PATCH 08/11] Add stream ID support for buffered mpage/__block_write_full_page() Jens Axboe
2016-03-04 16:10 ` [PATCH 09/11] btrfs: add support for write stream IDs Jens Axboe
2016-03-04 20:44 ` Chris Mason
2016-03-04 20:45 ` Jens Axboe
2016-03-04 16:10 ` [PATCH 10/11] xfs: add support for buffered writeback stream ID Jens Axboe
2016-03-04 16:10 ` [PATCH 11/11] ext4: add support for write stream IDs Jens Axboe
2016-03-04 19:42 ` [PATCH 0/11] Update version of write stream ID patchset Jeff Moyer
2016-03-04 20:34 ` Jens Axboe
2016-03-04 21:01 ` Jeff Moyer
2016-03-04 21:06 ` Jens Axboe
2016-03-04 22:03 ` Jeff Moyer
2016-03-04 22:13 ` Jens Axboe
2016-03-05 20:48 ` Martin K. Petersen
2016-03-08 21:56 ` Jens Axboe
2016-03-17 23:43 ` Dan Williams
2016-03-18 0:18 ` Jens Axboe
2016-03-18 2:39 ` Martin K. Petersen
2016-03-18 17:37 ` Jens Axboe
2016-03-18 17:56 ` Dan Williams
2016-03-06 6:13 ` Andreas Dilger
2016-03-06 13:03 ` Martin K. Petersen
2016-03-06 16:08 ` Boaz Harrosh
2016-03-06 20:51 ` Shaun Tancheff
2016-03-07 15:41 ` Martin K. Petersen
2016-03-07 15:34 ` Martin K. Petersen
2016-03-06 22:42 ` Andreas Dilger
2016-03-07 15:52 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1457107853-8689-4-git-send-email-axboe@fb.com \
--to=axboe@fb.com \
--cc=adilger@dilger.ca \
--cc=calvinowens@fb.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).