Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031323AbbKDWoU (ORCPT ); Wed, 4 Nov 2015 17:44:20 -0500 Received: from mail-bl2on0057.outbound.protection.outlook.com ([65.55.169.57]:9158 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1031007AbbKDWoN (ORCPT ); Wed, 4 Nov 2015 17:44:13 -0500 X-Greylist: delayed 19304 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Nov 2015 17:44:12 EST Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; X-AuditID: ac160a68-f790b6d00000123b-83-563a8a33dcf4 Subject: Re: [dm-devel] [PATCH 19/32] block: add helper to get data dir from op To: device-mapper development , , , , , References: <1446674909-5371-1-git-send-email-mchristi@redhat.com> <1446674909-5371-20-git-send-email-mchristi@redhat.com> CC: Mike Christie From: Bart Van Assche Message-ID: <563A8A33.3000002@sandisk.com> Date: Wed, 4 Nov 2015 14:44:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1446674909-5371-20-git-send-email-mchristi@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42JZI8azSNe4yyrM4OZffYu972azWjy8uoLF Ys/ekywWl3fNYbNon7+L0aL7+g42i/VHNjA6sHu0PGhj83i/7yqbx+dNcgHMUVw2Kak5mWWp Rfp2CVwZz34fYSno5q54s+wpYwPjB44uRk4OCQETie9/VrFD2GISF+6tZwOxhQROMEr8WlXS xcgFZG9nlDi7+wMzTMOkO4fYIBKbGCUapuwASwgLBEp0rm1lArFFBC4zSizep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ba66pP73/58u9/6yZ9CExbUfY1ZwuZlmFvO/djKYC Qbx8dz/pibKXfwya0W3y++Lu4JTzu40XFPmv0bnUH6jI9It137KzSizFGYmGWsxFxYkAEdOD 2w0CAAA= X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD047;1:6YeqZ4iQFqgHeXlOb/2QwcvVu9yfEkbKXGa+axY6WRQN9CaXmoFjoRKpdnUisiDDsTr2EPXMuckVHhbE7KQ1gUbv1hIhOGIjPwVAfhrnEA7QMssOthXXRUwb4mcNAVbOX/AIRUvcOAdIlT00MZUPtubwuh31Ok8TaOa58AW2rkOAEluckRgUyTawpfZUvK5JqJtCuzoLwDVJ2GJiG2CRmkv7lHhdgi+NSPzs254JPzFhxXchfdaac2GPp2nLXDMWMtv0c3TNYrt8fyZxiPJOmIJZyIbyTEYrPBymsDCswghIm1ZG3DD+PCM90esOqjV6fwrNw0w39X/4BDPhui2vmEBQ/4ProXxV2Et06k8eQqwdrFEwoNnZ9Eun0/3PWB4V X-Forefront-Antispam-Report: CIP:63.163.107.172;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(438002)(24454002)(479174004)(377454003)(199003)(51444003)(189002)(189998001)(76176999)(2950100001)(33656002)(36756003)(5008740100001)(106466001)(87266999)(50466002)(50986999)(65816999)(23746002)(230700001)(2201001)(4001350100001)(54356999)(65806001)(5001770100001)(86362001)(87936001)(64126003)(81156007)(83506001)(77096005)(5001960100002)(47776003)(19580405001)(92566002)(97736004)(65956001)(80316001)(59896002)(69596002)(19580395003)(5007970100001)(5001920100001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR02MB1391;H:milsmgep11.sandisk.com;FPR:;SPF:Pass;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;SN1PR02MB1391;2:kfBe7LxhHQrSH0ayuhl9tJRdHna7wgOWGAHWhQc2X0MVIyJubUJ+NwUw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xtQjYV686dwZJ1OZ+ol65noAA7DjsfvO4ufxswucIXCzz26QKbmc0lU9oK/u0s5dbbYfrJKZ3BBhGyyEF2zKvPi9bP/UlQeoi1LmipvNTrQ6RTo/8L5JmDV2AouPN3shyc6gvm7tkYlt54MJe7Ano5a9Wh/Dck5I4SXKrL1zDUFTxs/yGJLzfotRplcv829Q23gGJy9Mn4caOeqpeKztA/fVjKIDVYAfdlUvZU;4:44dAw/Pm3lDh2F/+WhPJq2Lqm2rkX2uSWARfNz3lu5hooLIIpfIvfYwhF6TqBPT6MLD0wQvk74VtyO0JHDQ2uWYvuhQXvwai81LiTQxKDnyrenpuT8b4Zy9Tzs8ag40dP5TD7pXvd4RFKfH2XQ+CtVxHfc2EsI8d1z/txSp2y5ceJswbOX+nY7kIKEsYmYHLTXujYJNGFOY4sgufN9brnl26Gs9aTEgefsYQicHAypccu0QWG6b3nIC3XZMpUybt6/usQmgDvTfWnpjwuaPils30QeIWVNFagLaKemRShOIGnJitbedTjtspaNhRhjbFX7na/ubHW3dqY8Tt9e3uHtxZbLg7MmszNepC2aut72y/9xs05DEp85UwMZkg7gg5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001);SRVR:SN1PR02MB1391;BCL:0;PCL:0;RULEID:;SRVR:SN1PR02MB1391; X-Forefront-PRVS: 0750463DC9 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;SN1PR02MB1391;23:wEVCzKMhar93sdxicwZIUOY6CxE27PrnuYpT/?= =?Windows-1252?Q?rvwGd1wo9ilFhXKoosfTk+OVCc9McqzoI1ZSI9JjKVSLOPdxlgeI4krF?= =?Windows-1252?Q?1T/HZ1IynMvfaK1XpcJIaiQcE89GLyzqcET6k4gNGuVLOHCFzahanLu8?= =?Windows-1252?Q?sUR1Q5BeFk76UuO0Agelfu4x7nmcoayvp9jNumznDiaTQs33cpvMFa4I?= =?Windows-1252?Q?9icCJZ0L0W+YHXd9zojI5KuhAgOKN29cFqtrJ6xecQr8XpiKSX6zXPbH?= =?Windows-1252?Q?IsRWDElQ0OQc2vhofy+pm173cCfpGVCeaGm9mWaWARFgPuOtz8ZpiHhK?= =?Windows-1252?Q?xSxABbRZfFRBfpDmKd94jgkm1C05skmef0bnvfXiHTWQ4gjGFFJ01au+?= =?Windows-1252?Q?D4iq8R9T+HzCIdLo54SmjltL6ZvxfwOdm4R5/1ltbOq5pElJPTkp3tEC?= =?Windows-1252?Q?K/EBObWLs/DryRrUUVnM68x87rxb6XuKH0vWz553nIJ3EdxhqdYdohtQ?= =?Windows-1252?Q?qpbc59ae5ivwavM3hn5FsFSC64QxFUwil2JUyk9VuTItkUCIwdmXFRrQ?= =?Windows-1252?Q?1xXg1Hp8EwRSxjBIUTjQD/IGTqkEAtKnynTLXkKgKn84UJUgnWVR6/mA?= =?Windows-1252?Q?engZlzevJYEDmGcgDhbVTMqJnpc+P9Cw9DEBuNpJP6/l/wiVQJP2jQOi?= =?Windows-1252?Q?1oVss8CQ/f0ZnwEQGIgbm/xLyl2vo1etGIyqd0LMy9iEOmh+B0nKHHgs?= =?Windows-1252?Q?83pXxY31MV3k8X6D2xNe/53OG36Gwgs1JlhWj0yG59EekMLuRdh0ez/H?= =?Windows-1252?Q?clVO53hlFDheJlXq0ynQRxEeDBwCabbA1eCd7/kpHZAghsuzgItz+Ox4?= =?Windows-1252?Q?fVIn7W5u65xFydcTaUuMvH90zZtIN111+BBGwjoaL71WJdHxL3R39Rss?= =?Windows-1252?Q?zInu2+k+mYlpXidVS30QXyKQEi+6y2Pv0qhFCAv1NsqSX5hM+mtDC/+I?= =?Windows-1252?Q?ZrGDeziHmcTJdi2KwyWX/jz6zeyCr/cRjmgm1n2GdMOS58aaJaz9bNE9?= =?Windows-1252?Q?J5qQYCFE17FZUNe8KFdcIMiC6zGMgT3/87Fgw8RXpADeqk36QYmGEV/k?= =?Windows-1252?Q?0qSIIcJyMAXN8WTYPVXK8IawykJdGn/9VSO4hDkGY2jU3UYATisVlPEY?= =?Windows-1252?Q?M2B38JFkXIhSZQApsTLmTEq5tIWEJWj5+0h7k2MUz2wJ5gLT3cz8VPjB?= =?Windows-1252?Q?ubjtq8/H8atu0eU5RVUOZp/ImGKdodXSbp06bPRitJ/2lqunPU+OZwT2?= =?Windows-1252?Q?IJH?= X-Microsoft-Exchange-Diagnostics: 1;SN1PR02MB1391;5:95euEmA+q0z0PbbamXidbsfy+4OZJmM68bvXgLbkp70d/nY25JgRm2B3ikdI2qPpSq30sptTr7bBiOtjWbdv/XFxJkYshjCYyK5y5CVPKO7Ce6KTDqokIRmSTRyAN6wZ06MuU3IFfVurzFIRUpq82A==;24:h/+Ea3fOzW6zr1fo+jD5iKmxj8/EI9+35ev2sB06FYg01LndfBTieCYp8dZOrKyXdS1wsFUKFP2v7q3KyWehGHvaOX24AEv/EFpY5ZV0vYI=;20:9rGEn3dQbNDM/RZAphjg3psEHH3pjUOZmmnFF3UmlLkW6ijveJ2afaQcStBRNqOgiwyRkJpHkcKQjdKm2GMHTuKBqxNQggQiUqpMHdPgfsRQ0XA77mXd0XP9CBvJ7+oBn3JcJN4OwV8n6Gcf9c5fw2ZY26VsjuvW0bLtGbKzht2Fq1vqCWiSEHlQasqdmiub0o42GsgriNC5VApOYarU/mDCHv9frDYHmh1sBUQxVMhaVQwczOLYgvUSS0u1FFu7 SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2015 22:44:07.2356 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d;Ip=[63.163.107.172];Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB1391 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1620 Lines: 49 On 11/04/2015 02:08 PM, mchristi@redhat.com wrote: > From: Mike Christie > > In later patches the op will no longer be a bitmap, so we will > not have REQ_WRITE set for all non reads like discard, flush, > and write same. Drivers will still want to treat them as writes > for accounting reasons, so this patch adds a helper to translate > a op to a data direction. > > Signed-off-by: Mike Christie > --- > include/linux/blkdev.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index 19c2e94..cf5f518 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -586,6 +586,18 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q) > > #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) > > +/* > + * Non REQ_OP_WRITE requests like discard, write same, etc, are > + * considered WRITEs. > + */ > +static inline int op_to_data_dir(int op) > +{ > + if (op == REQ_OP_READ) > + return READ; > + else > + return WRITE; > +} > + > #define rq_data_dir(rq) ((int)((rq)->cmd_flags & 1)) > > /* > How about introducing two functions - op_is_write() and op_is_read() ? I think that approach will result in shorter and easier to read code in the contexts where these functions are used. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/