Re: [PATCH] imsm: retry load_and_parse_mpb if we suspect mdmon has made modifications

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 02 Jun 2014 15:02:59 +0200 Artur Paszkiewicz
<artur.paszkiewicz@xxxxxxxxx> wrote:

> On 06/02/2014 04:36 AM, NeilBrown wrote:
> > On Fri, 30 May 2014 15:18:33 +0200 Artur Paszkiewicz
> > <artur.paszkiewicz@xxxxxxxxx> wrote:
> > 
> >> If the checksum verification fails in mdadm and mdmon is running, retry
> >> the load to get a consistent snapshot of the mpb.
> >>
> >> Based on db575f3b
> >>
> >> Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@xxxxxxxxx>
> >> Reviewed-by: Pawel Baldysiak <pawel.baldysiak@xxxxxxxxx>
> >> ---
> >>  super-intel.c | 17 +++++++++++++++++
> >>  1 file changed, 17 insertions(+)
> >>
> >> diff --git a/super-intel.c b/super-intel.c
> >> index f0a7ab5..037c018 100644
> >> --- a/super-intel.c
> >> +++ b/super-intel.c
> >> @@ -4422,6 +4422,7 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
> >>  {
> >>  	struct intel_super *super;
> >>  	int rv;
> >> +	int retry;
> >>  
> >>  	if (test_partition(fd))
> >>  		/* IMSM not allowed on partitions */
> >> @@ -4444,6 +4445,22 @@ static int load_super_imsm(struct supertype *st, int fd, char *devname)
> >>  	}
> >>  	rv = load_and_parse_mpb(fd, super, devname, 0);
> >>  
> >> +	/* retry the load if we might have raced against mdmon */
> >> +	if (rv == 3) {
> >> +		struct mdstat_ent *mdstat = mdstat_by_component(fd2devnm(fd));
> >> +
> >> +		if (mdmon_running(mdstat->devnm) && getpid() != mdmon_pid(mdstat->devnm)) {
> >> +			for (retry = 0; retry < 3; retry++) {
> >> +				usleep(3000);
> >> +				rv = load_and_parse_mpb(fd, super, devname, 0);
> >> +				if (rv != 3)
> >> +					break;
> >> +			}
> >> +		}
> > 
> > The only thing you use from mdstat is devnm, and that is the thing you passed
> > to mdstat_by_component to get mdstat....
> > 
> > Can you just do
> >    char *devnm = fd2devnm(fd);
> >    if (mdmon_running(devnm) && ......)
> > 
> > ??
> > 
> I can't do that because mdmon_running and mdmon_pid need a devnm of a
> container device, and the only thing we have here is the file descriptor
> of a component device. So I used mdstat_by_component to get the
> container devnm. Do you have an idea how to get that reliably without
> reading mdstat?
> 
> I have overlooked that mdstat_by_component can return NULL here. I've
> added a check for this in the patch below.


Right, of course, yes.
I've applied your patch - and thanks for the updated version.

NeilBrown

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux