All of lore.kernel.org
 help / color / mirror / Atom feed
From: keld@keldix.com
To: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Cc: linux-raid@vger.kernel.org, Jes.Sorensen@redhat.com,
	aleksey.obitotskiy@intel.com, pawel.baldysiak@intel.com,
	artur.paszkiewicz@intel.com, maksymilian.kunt@intel.com,
	mariusz.dabrowski@intel.com
Subject: Re: [PATCH 1/4] mdadm: bad block support for external metadata - initialization
Date: Thu, 20 Oct 2016 16:02:20 +0200	[thread overview]
Message-ID: <20161020140220.GB17867@www5.open-std.org> (raw)
In-Reply-To: <1476968626-19233-1-git-send-email-tomasz.majchrzak@intel.com>

Hi 

Is this safe for 2TB+ arrays?
I think the badblocks program does not handle 2TB+ partitions?

best regards
Keld

Best regards
Keld

On Thu, Oct 20, 2016 at 03:03:46PM +0200, Tomasz Majchrzak wrote:
> If metadata handler provides support for bad blocks, tell md by writing
> 'external_bbl' to rdev state file (both on create and assemble),
> followed by a list of known bad blocks written via sysfs 'bad_blocks'
> file.
> 
> Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
> Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
> ---
>  mdadm.h | 13 +++++++++++++
>  sysfs.c | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 41 insertions(+), 1 deletion(-)
> 
> diff --git a/mdadm.h b/mdadm.h
> index 0516c82..5156ea4 100755
> --- a/mdadm.h
> +++ b/mdadm.h
> @@ -237,6 +237,17 @@ struct dlm_lksb {
>  
>  extern const char Name[];
>  
> +struct md_bb_entry {
> +	unsigned long long sector;
> +	int length;
> +};
> +
> +struct md_bb {
> +	int supported;
> +	int count;
> +	struct md_bb_entry *entries;
> +};
> +
>  /* general information that might be extracted from a superblock */
>  struct mdinfo {
>  	mdu_array_info_t	array;
> @@ -311,6 +322,8 @@ struct mdinfo {
>  
>  	/* info read from sysfs */
>  	char		sysfs_array_state[20];
> +
> +	struct md_bb bb;
>  };
>  
>  struct createinfo {
> diff --git a/sysfs.c b/sysfs.c
> index d28e21a..c7a8e66 100644
> --- a/sysfs.c
> +++ b/sysfs.c
> @@ -50,8 +50,12 @@ void sysfs_free(struct mdinfo *sra)
>  		while (sra->devs) {
>  			struct mdinfo *d = sra->devs;
>  			sra->devs = d->next;
> +			if (d->bb.entries)
> +				free(d->bb.entries);
>  			free(d);
>  		}
> +		if (sra->bb.entries)
> +			free(sra->bb.entries);
>  		free(sra);
>  		sra = sra2;
>  	}
> @@ -259,7 +263,7 @@ struct mdinfo *sysfs_read(int fd, char *devnm, unsigned long options)
>  		dbase = base + strlen(base);
>  		*dbase++ = '/';
>  
> -		dev = xmalloc(sizeof(*dev));
> +		dev = xcalloc(1, sizeof(*dev));
>  
>  		/* Always get slot, major, minor */
>  		strcpy(dbase, "slot");
> @@ -687,6 +691,7 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume)
>  	char nm[PATH_MAX];
>  	char *dname;
>  	int rv;
> +	int i;
>  
>  	sprintf(dv, "%d:%d", sd->disk.major, sd->disk.minor);
>  	rv = sysfs_set_str(sra, NULL, "new_dev", dv);
> @@ -718,6 +723,28 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd, int resume)
>  		if (resume)
>  			sysfs_set_num(sra, sd, "recovery_start", sd->recovery_start);
>  	}
> +	if (sd->bb.supported) {
> +		if (sysfs_set_str(sra, sd, "state", "external_bbl")) {
> +			/*
> +			 * backward compatibility - if kernel doesn't support
> +			 * bad blocks for external metadata, let it continue
> +			 * as long as there are none known so far
> +			 */
> +			if (sd->bb.count) {
> +				pr_err("The kernel has no support for bad blocks in external metadata\n");
> +				return -1;
> +			}
> +		}
> +
> +		for (i = 0; i < sd->bb.count; i++) {
> +			char s[30];
> +			const struct md_bb_entry *entry = &sd->bb.entries[i];
> +
> +			snprintf(s, sizeof(s) - 1, "%llu %d\n", entry->sector,
> +				 entry->length);
> +			rv |= sysfs_set_str(sra, sd, "bad_blocks", s);
> +		}
> +	}
>  	return rv;
>  }
>  
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-10-20 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 13:03 [PATCH 1/4] mdadm: bad block support for external metadata - initialization Tomasz Majchrzak
2016-10-20 14:02 ` keld [this message]
2016-10-20 14:26   ` Tomasz Majchrzak
2016-10-26 18:00     ` Jes Sorensen
2016-10-26 19:23       ` Shaohua Li
2016-10-26 19:57         ` Jes Sorensen
2016-10-27  9:26           ` Tomasz Majchrzak
2016-11-28 13:34 [PATCH 1/4 v2] " Jes Sorensen
2016-11-28 14:07 ` [PATCH 1/4] " Tomasz Majchrzak
2016-11-28 22:45   ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161020140220.GB17867@www5.open-std.org \
    --to=keld@keldix.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=aleksey.obitotskiy@intel.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=maksymilian.kunt@intel.com \
    --cc=mariusz.dabrowski@intel.com \
    --cc=pawel.baldysiak@intel.com \
    --cc=tomasz.majchrzak@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.