From 134bcc1bfb17f4ebd8305b4f541d281bc098069d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 5 May 2019 17:48:02 -0700 Subject: [PATCH] ircd::fs: Add write_opts for RWF_WRITE_LIFE_* support. --- include/ircd/fs/write.h | 6 ++++++ ircd/fs.cc | 5 +++++ ircd/fs_aio.cc | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/include/ircd/fs/write.h b/include/ircd/fs/write.h index 89b935689..a12102b58 100644 --- a/include/ircd/fs/write.h +++ b/include/ircd/fs/write.h @@ -83,6 +83,12 @@ struct ircd::fs::write_opts /// write with fsync(2)/fdsync(2) yourself. bool metadata {false}; + /// RWH_WRITE_LIFE integer representation (see fcntl(2) since Linux 4.13) if + /// supported; otherwise has no effect. As a write_opts option, this is only + /// meaningful if pwritev2(2) is available and the kernel recognizes the + /// RWF_WRITE_LIFE flag bits. See also fs::write_life(fd). + uint8_t write_life {0}; + write_opts(const off_t & = 0); }; diff --git a/ircd/fs.cc b/ircd/fs.cc index 86f048caa..6bf93a047 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -1317,6 +1317,11 @@ ircd::fs::flags(const write_opts &opts) ret |= RWF_SYNC; #endif + #ifdef RWF_WRITE_LIFE_SHIFT + if(support_rwf_write_life && opts.write_life) + ret |= (opts.write_life << (RWF_WRITE_LIFE_SHIFT)); + #endif + return ret; } diff --git a/ircd/fs_aio.cc b/ircd/fs_aio.cc index 04e9c0a7f..7125fc0b2 100644 --- a/ircd/fs_aio.cc +++ b/ircd/fs_aio.cc @@ -276,6 +276,11 @@ ircd::fs::aio::request::write::write(const int &fd, if(support_sync && opts.sync && opts.metadata) aio_rw_flags |= RWF_SYNC; #endif + + #ifdef RWF_WRITE_LIFE_SHIFT + if(support_rwf_write_life && opts.write_life) + aio_rw_flags |= (opts.write_life << (RWF_WRITE_LIFE_SHIFT)); + #endif } size_t