forked from mirrors/linux
		
	md/raid1: support read error check
After commit 1e50915fe0 ("raid: improve MD/raid10 handling of correctable
read errors."), rdev will be set to faulty if it reads data error to many
times in raid10. Add this mechanism to raid1 now.
Signed-off-by: Li Nan <linan122@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20231215023852.3478228-3-linan666@huaweicloud.com
			
			
This commit is contained in:
		
							parent
							
								
									1979dbbe32
								
							
						
					
					
						commit
						ca294b34aa
					
				
					 1 changed files with 12 additions and 5 deletions
				
			
		| 
						 | 
					@ -2256,16 +2256,24 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
 | 
				
			||||||
 *	3.	Performs writes following reads for array synchronising.
 | 
					 *	3.	Performs writes following reads for array synchronising.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void fix_read_error(struct r1conf *conf, int read_disk,
 | 
					static void fix_read_error(struct r1conf *conf, struct r1bio *r1_bio)
 | 
				
			||||||
			   sector_t sect, int sectors)
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						sector_t sect = r1_bio->sector;
 | 
				
			||||||
 | 
						int sectors = r1_bio->sectors;
 | 
				
			||||||
 | 
						int read_disk = r1_bio->read_disk;
 | 
				
			||||||
	struct mddev *mddev = conf->mddev;
 | 
						struct mddev *mddev = conf->mddev;
 | 
				
			||||||
 | 
						struct md_rdev *rdev = rcu_dereference(conf->mirrors[read_disk].rdev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (exceed_read_errors(mddev, rdev)) {
 | 
				
			||||||
 | 
							r1_bio->bios[r1_bio->read_disk] = IO_BLOCKED;
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while(sectors) {
 | 
						while(sectors) {
 | 
				
			||||||
		int s = sectors;
 | 
							int s = sectors;
 | 
				
			||||||
		int d = read_disk;
 | 
							int d = read_disk;
 | 
				
			||||||
		int success = 0;
 | 
							int success = 0;
 | 
				
			||||||
		int start;
 | 
							int start;
 | 
				
			||||||
		struct md_rdev *rdev;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (s > (PAGE_SIZE>>9))
 | 
							if (s > (PAGE_SIZE>>9))
 | 
				
			||||||
			s = PAGE_SIZE >> 9;
 | 
								s = PAGE_SIZE >> 9;
 | 
				
			||||||
| 
						 | 
					@ -2506,8 +2514,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
 | 
				
			||||||
	if (mddev->ro == 0
 | 
						if (mddev->ro == 0
 | 
				
			||||||
	    && !test_bit(FailFast, &rdev->flags)) {
 | 
						    && !test_bit(FailFast, &rdev->flags)) {
 | 
				
			||||||
		freeze_array(conf, 1);
 | 
							freeze_array(conf, 1);
 | 
				
			||||||
		fix_read_error(conf, r1_bio->read_disk,
 | 
							fix_read_error(conf, r1_bio);
 | 
				
			||||||
			       r1_bio->sector, r1_bio->sectors);
 | 
					 | 
				
			||||||
		unfreeze_array(conf);
 | 
							unfreeze_array(conf);
 | 
				
			||||||
	} else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) {
 | 
						} else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) {
 | 
				
			||||||
		md_error(mddev, rdev);
 | 
							md_error(mddev, rdev);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue