From patchwork Tue Feb 28 14:57:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9595935 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 8EF60601D7 for ; Tue, 28 Feb 2017 14:58:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D6528497 for ; Tue, 28 Feb 2017 14:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79C1A284FF; Tue, 28 Feb 2017 14:58:43 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 3D3A428497 for ; Tue, 28 Feb 2017 14:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752453AbdB1O6U (ORCPT ); Tue, 28 Feb 2017 09:58:20 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:34518 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752156AbdB1O6E (ORCPT ); Tue, 28 Feb 2017 09:58:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C63ykedmuqLG+OCumLjwEU92Xz55wCuvU88ej4j/RPY=; b=M+PakoXA45mkcC313o9iTDg2j 8iGbe8Y5lwHXOal8ZMwXPF1OJ99UHfPWd1TnJiof9wtuuz/icwLx4vXqzn8mi9EmUTQsCYN+UyYSA Z5PvJM6zZ5aISNIO1TVrd3BwC6cOwxPt8LAbqsKzWLHJyFrwnEwJzKlqXQvZEqo7qLOf0UdvCHEi8 m0T5naBhxuLRrPiO9EEg1g0z66PEuYAs/QLGExeu+DhMUPx4VSrLFbhP1lnyzO3Bt1cGrBEtK9IEJ pJamihgO8csxZh0Q31iJmhKgwYsXKnVryDdHvnOsOOACFyiF0UUl+/r9qOpXu8RQPakGs384gMlwS 6j5wTzZcw==; Received: from [8.25.222.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cijDf-0006SE-33; Tue, 28 Feb 2017 14:57:39 +0000 From: Christoph Hellwig To: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH 11/12] block_dev: implement the F_IOINFO fcntl Date: Tue, 28 Feb 2017 06:57:36 -0800 Message-Id: <20170228145737.19016-12-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170228145737.19016-1-hch@lst.de> References: <20170228145737.19016-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/fs/block_dev.c b/fs/block_dev.c index 4dd5c54cdefb..48a799964e1d 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -2116,6 +2116,26 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start, end >> PAGE_SHIFT); } +static int blkdev_ioinfo(struct file *file, struct fcntl_ioinfo *fio) +{ + struct block_device *bdev = I_BDEV(bdev_file_inode(file)); + struct request_queue *q = bdev_get_queue(bdev); + unsigned int atomic_sectors = queue_max_atomic_write_sectors(q); + + if (file->f_flags & O_DIRECT) { + fio->fio_alignment = bdev_logical_block_size(bdev); + + if ((file->f_flags & O_ATOMIC) && atomic_sectors) { + fio->fio_flags = FIO_FL_ATOMIC_OSYNC; + fio->fio_max_atomic = (atomic_sectors << 9); + if (fio->fio_alignment) + fio->fio_max_atomic &= ~(fio->fio_alignment - 1); + } + } + + return 0; +}; + const struct file_operations def_blk_fops = { .open = blkdev_open, .release = blkdev_close, @@ -2131,6 +2151,7 @@ const struct file_operations def_blk_fops = { .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = blkdev_fallocate, + .ioinfo = blkdev_ioinfo, }; int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)