From patchwork Sat Aug 1 09:51:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Biao X-Patchwork-Id: 6922101 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B7AF8C05AC for ; Sat, 1 Aug 2015 09:52:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D47E204FB for ; Sat, 1 Aug 2015 09:52:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02F7420460 for ; Sat, 1 Aug 2015 09:52:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751183AbbHAJwH (ORCPT ); Sat, 1 Aug 2015 05:52:07 -0400 Received: from mx5.zte.com.cn ([63.217.80.70]:41846 "EHLO mx5.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751171AbbHAJwG (ORCPT ); Sat, 1 Aug 2015 05:52:06 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Websense Email Security Gateway with ESMTPS id 9E8162A26455A; Sat, 1 Aug 2015 17:51:59 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id t719pujO054098; Sat, 1 Aug 2015 17:51:56 +0800 (GMT-8) (envelope-from jiang.biao2@zte.com.cn) To: linux-scsi@vger.kernel.org, JBottomley@odin.com Subject: [Patch] scsi_ioctl: support persistent reserve commands through ioctl for non-root user. MIME-Version: 1.0 X-KeepSent: 31114848:5C193F0C-48257E94:00359001; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 Message-ID: From: jiang.biao2@zte.com.cn Date: Sat, 1 Aug 2015 17:51:38 +0800 X-MIMETrack: Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2015-08-01 17:51:52, Serialize complete at 2015-08-01 17:51:52 X-MAIL: mse01.zte.com.cn t719pujO054098 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY, URIBL_BLACK autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP scsi_ioctl: support persistent reserve commands through ioctl for non-root user. Scsi persistent reserve commands need to be used for non-root user in many scenarios. EPERM error will be returned by sg_io() when PERSISTENT_RESERVE_OUT or PERSISTENT_RESERVE_IN command is sent through ioctl() for non-root user. Add PERSISTENT_RESERVE_OUT and PERSISTENT_RESERVE_IN into blk_default_cmd_filter in blk_set_cmd_filter_defaults() to support persistent reserve commands for non-root user. Signed-off-by: Jiang Biao Signed-off-by: Li Ping Reviewed-by: Liu Jianjun diff -urpN block/scsi_ioctl.c block_new/scsi_ioctl.c --- block/scsi_ioctl.c 2015-08-01 17:07:47.000000000 +0800 +++ block_new/scsi_ioctl.c 2015-08-01 17:09:56.000000000 +0800 @@ -202,6 +202,9 @@ static void blk_set_cmd_filter_defaults( __set_bit(GPCMD_LOAD_UNLOAD, filter->write_ok); __set_bit(GPCMD_SET_STREAMING, filter->write_ok); __set_bit(GPCMD_SET_READ_AHEAD, filter->write_ok); + /* Persistent reserve command*/ + __set_bit(PERSISTENT_RESERVE_IN, filter->read_ok); + __set_bit(PERSISTENT_RESERVE_OUT, filter->write_ok); } int blk_verify_command(unsigned char *cmd, fmode_t has_write_perm)