Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4634843imm; Fri, 18 May 2018 08:14:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrCGpQL64XUYPekfBMaIW2uTkl8XobsAXngrwyDd/vRefT8QRMgu4g57/R4zHB87coWk5mW X-Received: by 2002:a17:902:b087:: with SMTP id p7-v6mr9919832plr.227.1526656483927; Fri, 18 May 2018 08:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526656483; cv=none; d=google.com; s=arc-20160816; b=iOTv1PxYacqTjVDkYXBqw+HOE8E3xniuga9OiCS6+F017XQZcKktBpR0ENgAeNM3/p A8oKQwPEha91gGFe3gF6Lg99EuGTNiYv1+/1lPop9JDoMgGE7Ic5pgE7aVeojJOQODie xJxhesaMWls3I4A7QtxmWUKQW1OSidvQKi4iM8crobqHjYESW0HkhIKg0s90QN8cWDvB CrsZcDqpsRxREP4n9kilpvAXbIA578TkoQle29LmAxeD616/9vJG6jAkNOrKkE9SvEvJ 6VmIkM5FjoQosiWY6VOr7BWqjTSEzAHWQjQg1DnJRjPe8aQA7DV7rNZKuoEy6aQfHOdu IqTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Sdxr38V5YQc092pPjeavYodUwFp9EY3rmLVMEJcULkg=; b=UHGyI35sLuXWKUUbUXPK5y3q2BgPmwE/ZLfIgM5NyeILGFMxUcvn5iF/4BKf8rW8+n Y8hE4WG410VtlpkI1NEn1Neu89vDMXafkS9OUaIfO+0E1lAt6OL6diZVNMB5FtjHOAwu ce7c3VwkBumHVXHtHX6fSlTW4BnQ1QLS7ewie/hh6DN9qXokORrEz24HUYZABjGTFXP/ BAIbZvknTSKc6wqjfBRZCE90dzVq8/uFe07OP9oWrI31JuVpNJ6cnO+jVj9M9dGbSFsx F0bCpQcJvagKh1LLMQH2Wd6ZwJ5XjvXNyuEmGby2Fd7suxVEoolDKL5UcoB/6aMtC5YL HPag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=0bcwunU9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u123-v6si7221671pfu.322.2018.05.18.08.14.30; Fri, 18 May 2018 08:14:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=0bcwunU9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752366AbeERPOP (ORCPT + 99 others); Fri, 18 May 2018 11:14:15 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:38368 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751363AbeERPOM (ORCPT ); Fri, 18 May 2018 11:14:12 -0400 Received: by mail-it0-f65.google.com with SMTP id q4-v6so13561114ite.3 for ; Fri, 18 May 2018 08:14:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Sdxr38V5YQc092pPjeavYodUwFp9EY3rmLVMEJcULkg=; b=0bcwunU9DSfEZ4OWOdGWmHMwDtnMbu9wms7vJK6/oY+qfo8IGck7nSW5QvLgCQ0ko5 UgDb5xRUkWTbnQrhz8bIRsnxc9E5HfcZF0XFj9f4xmMpPKBAJzyAnSdAEl4w/eRGVKy6 7c0b8BMKRKk2B/eWTQViFYxN5YogZZviahq+JkjUzbCtf50gKJPwVGcGk43hnuEi3Ikt WO3EhtQYN3GWWtbY7oqxihZYR6+Tf/qojF4ZM+CDq+8uY252MA1l9nGq3ERn+I0rgEE7 BLK8PehgF+pKqBrrOJ/IlovK38JSG/XG8ib/8bfgGiHEyHTxmtZzTsmrwpwA+gScDKEk Jzqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Sdxr38V5YQc092pPjeavYodUwFp9EY3rmLVMEJcULkg=; b=Mgf0Yu49Jrt0KF46ISXgzGjrNBsoaDz+rgx064iozAys3AwjmcBvddDtusKEoAhLmv 2lqG7FOvyhidh9riWs3KMJM/iqJYJEc2tazbJaXE//uX4jtTN+kjOhzR+6mOC78ej0qq MT9pT9/ZwElCh462DfIWIrwOk49W0WAzIzeHQHw5ol8sdgbiFJDX+TwmC3SSCYqo4ien RLOce+1zTxxpsrOs3+BMdcAg6Qko8PRKYrQ9ZNYlcOE0Bu2W3d9J0oidYg2tZE3K0zKq 0sabXmJiajWQQWl/PgjVpZCtCjg18D80kXAyeU/4xJpZRTbDIcr6mQ3GJ+w+n9cCvoMr kD6A== X-Gm-Message-State: ALKqPwdRASMXphi7fOC5Y3+T8RUXo5iWNYRqdLdX8jQdJqUbaP+wo2HL ZeziLO9jZ1CCZjjCO8+rGRgY1A== X-Received: by 2002:a24:874a:: with SMTP id f71-v6mr8244694ite.69.1526656451496; Fri, 18 May 2018 08:14:11 -0700 (PDT) Received: from [192.168.1.167] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id u83-v6sm4733731itf.44.2018.05.18.08.14.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 May 2018 08:14:10 -0700 (PDT) Subject: Re: [PATCH v4 3/3] fs: Add aio iopriority support for block_dev To: adam.manzanares@wdc.com, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, bcrl@kvack.org Cc: mingo@kernel.org, peterz@infradead.org, pombredanne@nexb.com, gregkh@linuxfoundation.org, bigeasy@linutronix.de, rgoldwyn@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, linux-api@vger.kernel.org References: <20180517203803.2664-1-adam.manzanares@wdc.com> <20180517203803.2664-4-adam.manzanares@wdc.com> From: Jens Axboe Message-ID: <51cbf2e9-1ff9-b9e7-fb68-055a64d54da5@kernel.dk> Date: Fri, 18 May 2018 09:14:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180517203803.2664-4-adam.manzanares@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/17/18 2:38 PM, adam.manzanares@wdc.com wrote: > From: Adam Manzanares > > This is the per-I/O equivalent of the ioprio_set system call. > > When IOCB_FLAG_IOPRIO is set on the iocb aio_flags field, then we set the > newly added kiocb ki_ioprio field to the value in the iocb aio_reqprio field. > > When a bio is created for an aio request by the block dev we set the priority > value of the bio to the user supplied value. > > This patch depends on block: add ioprio_check_cap function Actually, one comment on this one: > diff --git a/fs/aio.c b/fs/aio.c > index f3eae5d5771b..ff3107aa82d5 100644 > --- a/fs/aio.c > +++ b/fs/aio.c > @@ -1451,6 +1451,22 @@ static int aio_prep_rw(struct kiocb *req, struct iocb *iocb) > if (iocb->aio_flags & IOCB_FLAG_RESFD) > req->ki_flags |= IOCB_EVENTFD; > req->ki_hint = file_write_hint(req->ki_filp); > + if (iocb->aio_flags & IOCB_FLAG_IOPRIO) { > + /* > + * If the IOCB_FLAG_IOPRIO flag of aio_flags is set, then > + * aio_reqprio is interpreted as an I/O scheduling > + * class and priority. > + */ > + ret = ioprio_check_cap(iocb->aio_reqprio); > + if (ret) { > + pr_debug("aio ioprio check cap error\n"); > + return -EINVAL; > + } > + > + req->ki_ioprio = iocb->aio_reqprio; > + req->ki_flags |= IOCB_IOPRIO; > + } Do we really need IOCB_IOPRIO? All zeroes is no priority set anyway, so we should be able to get by with just setting ->ki_ioprio to either the priority, or 0. > diff --git a/fs/block_dev.c b/fs/block_dev.c > index 7ec920e27065..970bef79caa6 100644 > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -355,6 +355,8 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) > bio->bi_write_hint = iocb->ki_hint; > bio->bi_private = dio; > bio->bi_end_io = blkdev_bio_end_io; > + if (iocb->ki_flags & IOCB_IOPRIO) > + bio->bi_ioprio = iocb->ki_ioprio; And then this assignment can just happen unconditionally. -- Jens Axboe