From patchwork Wed Jul 8 11:09:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 6745031 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 F3E75C05AC for ; Wed, 8 Jul 2015 11:10:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 363AB2060F for ; Wed, 8 Jul 2015 11:10:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94E2420621 for ; Wed, 8 Jul 2015 11:10:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933897AbbGHLKH (ORCPT ); Wed, 8 Jul 2015 07:10:07 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45661 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933796AbbGHLJw (ORCPT ); Wed, 8 Jul 2015 07:09:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 56243ABA5; Wed, 8 Jul 2015 11:09:50 +0000 (UTC) From: Hannes Reinecke To: James Bottomley Cc: Bart van Assche , Christoph Hellwig , linux-scsi@vger.kernel.org, Ewan Milne , Hannes Reinecke Subject: [PATCH 5/5] scsi_dh_rdac: Add 'state' callback Date: Wed, 8 Jul 2015 13:09:48 +0200 Message-Id: <1436353788-104911-6-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1436353788-104911-1-git-send-email-hare@suse.de> References: <1436353788-104911-1-git-send-email-hare@suse.de> 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.6 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 Add a 'state' callback to display the current LUN access state to sysfs. Signed-off-by: Hannes Reinecke --- drivers/scsi/device_handler/scsi_dh_rdac.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 3613581..151b736 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -834,6 +834,22 @@ static void rdac_bus_detach( struct scsi_device *sdev ) kfree(h); } +static int rdac_state(struct scsi_device *sdev) +{ + struct rdac_dh_data *h = sdev->handler_data; + int access_state = SCSI_ACCESS_STATE_OPTIMAL; + + if (h->lun_state == RDAC_LUN_UNOWNED) + access_state = SCSI_ACCESS_STATE_ACTIVE; + if (h->state == RDAC_STATE_PASSIVE) + access_state = SCSI_ACCESS_STATE_PASSIVE; + + if (h->preferred == RDAC_PREFERRED) + access_state |= SCSI_ACCESS_STATE_PREFERRED; + + return access_state; +} + static struct scsi_device_handler rdac_dh = { .name = RDAC_NAME, .module = THIS_MODULE, @@ -842,6 +858,7 @@ static struct scsi_device_handler rdac_dh = { .attach = rdac_bus_attach, .detach = rdac_bus_detach, .activate = rdac_activate, + .state = rdac_state, }; static int __init rdac_init(void)