From patchwork Tue Aug 4 01:11:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Biao X-Patchwork-Id: 6933661 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9FB419F358 for ; Tue, 4 Aug 2015 01:12:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 341962060B for ; Tue, 4 Aug 2015 01:12:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 24086205FF for ; Tue, 4 Aug 2015 01:12:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754409AbbHDBMH (ORCPT ); Mon, 3 Aug 2015 21:12:07 -0400 Received: from mx7.zte.com.cn ([202.103.147.169]:35277 "EHLO zte.com.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754071AbbHDBMG (ORCPT ); Mon, 3 Aug 2015 21:12:06 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Websense Email Security Gateway with ESMTPS id 3FCEA9FFF3320; Tue, 4 Aug 2015 09:11:56 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id t741Bjwv013818; Tue, 4 Aug 2015 09:11:45 +0800 (GMT-8) (envelope-from jiang.biao2@zte.com.cn) To: James Bottomley Cc: Hannes Reinecke , linux-scsi@vger.kernel.org Subject: [Patch] scsi_ioctl: support persistent reserve commands for non-root user. MIME-Version: 1.0 X-KeepSent: 27ABBEA2:0BA86E1E-48257E97:0004D192; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.3 September 15, 2011 Message-ID: From: jiang.biao2@zte.com.cn Date: Tue, 4 Aug 2015 09:11:45 +0800 X-MIMETrack: Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2015-08-04 09:11:30, Serialize complete at 2015-08-04 09:11:30 X-MAIL: mse01.zte.com.cn t741Bjwv013818 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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)