From: Christoph Hellwig <hch@lst.de> To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 03/12] iomap: add a IOMAP_ATOMIC flag Date: Tue, 28 Feb 2017 06:57:28 -0800 [thread overview] Message-ID: <20170228145737.19016-4-hch@lst.de> (raw) In-Reply-To: <20170228145737.19016-1-hch@lst.de> To pass through O_ATOMIC to the iomap_begin methods. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/iomap.c | 13 +++++++++++-- include/linux/iomap.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/iomap.c b/fs/iomap.c index 16a9d2b89cb6..096cbf573932 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -237,6 +237,10 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *iter, { struct inode *inode = iocb->ki_filp->f_mapping->host; loff_t pos = iocb->ki_pos, ret = 0, written = 0; + unsigned flags = IOMAP_WRITE; + + if (iocb->ki_filp->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; while (iov_iter_count(iter)) { ret = iomap_apply(inode, pos, iov_iter_count(iter), @@ -452,8 +456,12 @@ int iomap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, struct inode *inode = file_inode(vma->vm_file); unsigned long length; loff_t offset, size; + unsigned flags = IOMAP_WRITE | IOMAP_FAULT; ssize_t ret; + if (vma->vm_file->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; + lock_page(page); size = i_size_read(inode); if ((page->mapping != inode->i_mapping) || @@ -471,8 +479,7 @@ int iomap_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, offset = page_offset(page); while (length > 0) { - ret = iomap_apply(inode, offset, length, - IOMAP_WRITE | IOMAP_FAULT, ops, page, + ret = iomap_apply(inode, offset, length, flags, ops, page, iomap_page_mkwrite_actor); if (unlikely(ret <= 0)) goto out_unlock; @@ -883,6 +890,8 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, } else { dio->flags |= IOMAP_DIO_WRITE; flags |= IOMAP_WRITE; + if (iocb->ki_filp->f_flags & O_ATOMIC) + flags |= IOMAP_ATOMIC; } if (mapping->nrpages) { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 891459caa278..a670ff18ccd6 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -51,6 +51,7 @@ struct iomap { #define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */ #define IOMAP_FAULT (1 << 3) /* mapping for page fault */ #define IOMAP_DIRECT (1 << 4) /* direct I/O */ +#define IOMAP_ATOMIC (1 << 5) /* atomic write vs power fail */ struct iomap_ops { /* -- 2.11.0
next prev parent reply other threads:[~2017-02-28 14:58 UTC|newest] Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-02-28 14:57 [RFC] failure atomic writes for file systems and block devices Christoph Hellwig 2017-02-28 14:57 ` [PATCH 01/12] uapi/fs: add O_ATOMIC to the open flags Christoph Hellwig 2017-02-28 14:57 ` [PATCH 02/12] iomap: pass IOMAP_* flags to actors Christoph Hellwig 2017-02-28 14:57 ` Christoph Hellwig [this message] 2017-02-28 14:57 ` [PATCH 04/12] fs: add a BH_Atomic flag Christoph Hellwig 2017-02-28 14:57 ` [PATCH 05/12] fs: add a F_IOINFO fcntl Christoph Hellwig 2017-02-28 16:51 ` Darrick J. Wong 2017-03-01 15:11 ` Christoph Hellwig 2017-02-28 14:57 ` [PATCH 06/12] xfs: cleanup is_reflink checks Christoph Hellwig 2017-02-28 14:57 ` [PATCH 07/12] xfs: implement failure-atomic writes Christoph Hellwig 2017-02-28 23:09 ` Darrick J. Wong 2017-03-01 15:17 ` Christoph Hellwig 2017-02-28 14:57 ` [PATCH 08/12] xfs: implement the F_IOINFO fcntl Christoph Hellwig 2017-02-28 14:57 ` [PATCH 09/12] block: advertize max atomic write limit Christoph Hellwig 2017-02-28 14:57 ` [PATCH 10/12] block_dev: set REQ_NOMERGE for O_ATOMIC writes Christoph Hellwig 2017-02-28 14:57 ` [PATCH 11/12] block_dev: implement the F_IOINFO fcntl Christoph Hellwig 2017-02-28 14:57 ` [PATCH 12/12] nvme: export the atomic write limit Christoph Hellwig 2017-02-28 20:48 ` [RFC] failure atomic writes for file systems and block devices Chris Mason 2017-02-28 20:48 ` Chris Mason 2017-03-01 15:07 ` Christoph Hellwig 2017-02-28 23:22 ` Darrick J. Wong 2017-03-01 15:09 ` Christoph Hellwig 2017-03-01 11:21 ` Amir Goldstein 2017-03-01 15:07 ` Christoph Hellwig 2017-03-01 15:07 ` Christoph Hellwig
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=20170228145737.19016-4-hch@lst.de \ --to=hch@lst.de \ --cc=linux-block@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-xfs@vger.kernel.org \ --subject='Re: [PATCH 03/12] iomap: add a IOMAP_ATOMIC flag' \ /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
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.