From patchwork Thu Mar 18 13:59:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 86718 Received: from mx02.colomx.prod.int.phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2IE0Nxd009564 for ; Thu, 18 Mar 2010 14:00:58 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx02.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IDxEGU016102; Thu, 18 Mar 2010 09:59:14 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IDxCcI026145 for ; Thu, 18 Mar 2010 09:59:12 -0400 Received: from localhost.localdomain (vpn2-9-191.ams2.redhat.com [10.36.9.191]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2IDx5vB031246; Thu, 18 Mar 2010 09:59:06 -0400 From: Milan Broz To: dm-devel@redhat.com Date: Thu, 18 Mar 2010 14:59:00 +0100 Message-Id: <1268920740-11015-1-git-send-email-mbroz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-loop: dm-devel@redhat.com Cc: Milan Broz Subject: [dm-devel] [PATCH] Add suspend change flag into dm-ioctl. X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 18 Mar 2010 14:00:59 +0000 (UTC) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b670922..5d33492 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -596,7 +596,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param) struct dm_table *table; param->flags &= ~(DM_SUSPEND_FLAG | DM_READONLY_FLAG | - DM_ACTIVE_PRESENT_FLAG); + DM_SUSPEND_CHANGE_FLAG | DM_ACTIVE_PRESENT_FLAG); if (dm_suspended_md(md)) param->flags |= DM_SUSPEND_FLAG; @@ -846,7 +846,7 @@ out: static int do_suspend(struct dm_ioctl *param) { - int r = 0; + int r = 0, suspended = 0; unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG; struct mapped_device *md; @@ -859,11 +859,17 @@ static int do_suspend(struct dm_ioctl *param) if (param->flags & DM_NOFLUSH_FLAG) suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG; - if (!dm_suspended_md(md)) + if (!dm_suspended_md(md)) { r = dm_suspend(md, suspend_flags); + if (!r) + suspended = 1; + } - if (!r) + if (!r) { r = __dev_status(md, param); + if (suspended) + param->flags |= DM_SUSPEND_CHANGE_FLAG; + } dm_put(md); return r; @@ -871,7 +877,7 @@ static int do_suspend(struct dm_ioctl *param) static int do_resume(struct dm_ioctl *param) { - int r = 0; + int r = 0, resumed = 0; unsigned suspend_flags = DM_SUSPEND_LOCKFS_FLAG; struct hash_cell *hc; struct mapped_device *md; @@ -919,16 +925,21 @@ static int do_resume(struct dm_ioctl *param) if (dm_suspended_md(md)) { r = dm_resume(md); - if (!r) + if (!r) { dm_ioctl_uevent(md, KOBJ_CHANGE, param->event_nr, ¶m->flags); + resumed = 1; + } } if (old_map) dm_table_destroy(old_map); - if (!r) + if (!r) { r = __dev_status(md, param); + if (resumed) + param->flags |= DM_SUSPEND_CHANGE_FLAG; + } dm_put(md); return r; diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index 2c445e1..ae957a3 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited. - * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004 - 2010 Red Hat, Inc. All rights reserved. * * This file is released under the LGPL. */ @@ -266,9 +266,9 @@ enum { #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 17 +#define DM_VERSION_MINOR 18 #define DM_VERSION_PATCHLEVEL 0 -#define DM_VERSION_EXTRA "-ioctl (2010-03-05)" +#define DM_VERSION_EXTRA "-ioctl (2010-03-10)" /* Status bits */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */ @@ -321,4 +321,9 @@ enum { */ #define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */ +/* + * If set, suspend state of device changed from previous state. + */ +#define DM_SUSPEND_CHANGE_FLAG (1 << 14) /* Out */ + #endif /* _LINUX_DM_IOCTL_H */