96 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
		
		
			
		
	
	
			96 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
|  | From: rajan.shanmugavelu@oracle.com | ||
|  | Date: Mon 27 Nov 2023 09:02:28 AM PST | ||
|  | Subject: [PATCH] Oracleasm: fix SLE-15-SP5 issues | ||
|  | Patch-mainline: never (Oracle KMP specific) | ||
|  | References: bsc#1215781 | ||
|  | 
 | ||
|  | Various fixes to get oracleasm KMP driver working correctly for | ||
|  | SLE-15-SP5:Update. | ||
|  | 
 | ||
|  | Signed-off-by: Lee Duncan <lduncan@suse.com> | ||
|  | ---
 | ||
|  |  drivers/block/oracleasm/driver.c |   25 +++++++++++++++++-------- | ||
|  |  1 file changed, 17 insertions(+), 8 deletions(-) | ||
|  | 
 | ||
|  | --- a/drivers/block/oracleasm/driver.c
 | ||
|  | +++ b/drivers/block/oracleasm/driver.c
 | ||
|  | @@ -72,6 +72,7 @@
 | ||
|  |  #include <linux/compat.h> | ||
|  |  #include <linux/log2.h> | ||
|  |  #include <linux/bug.h> | ||
|  | +#include <linux/bio.h>
 | ||
|  |   | ||
|  |  #include <asm/uaccess.h> | ||
|  |  #include <linux/spinlock.h> | ||
|  | @@ -149,8 +150,9 @@ void asm_bio_unmap(struct bio *bio)
 | ||
|  |  { | ||
|  |  	bio_release_pages(bio, bio_data_dir(bio) == READ); | ||
|  |  	bio_put(bio); | ||
|  | -	bio_put(bio);
 | ||
|  | +	bio_cnt_set(bio, 0);
 | ||
|  |  	trace_bio(bio, "released"); | ||
|  | +	kfree(bio);
 | ||
|  |  } | ||
|  |   | ||
|  |  /* | ||
|  | @@ -1140,8 +1142,9 @@ static void asm_end_bio_io(struct bio *b
 | ||
|  |   | ||
|  |   | ||
|  |  static struct bio *asm_bio_map_user_iov(struct request_queue *q, | ||
|  | -                struct iov_iter *iter, gfp_t gfp_mask)
 | ||
|  | +                struct iov_iter *iter, gfp_t gfp_mask, int rw)
 | ||
|  |  { | ||
|  | +	unsigned int nr_vecs = iov_iter_npages(iter, BIO_MAX_VECS);
 | ||
|  |          struct bio *bio; | ||
|  |          int ret; | ||
|  |          int j; | ||
|  | @@ -1149,9 +1152,12 @@ static struct bio *asm_bio_map_user_iov(
 | ||
|  |          if (!iov_iter_count(iter)) | ||
|  |                  return ERR_PTR(-EINVAL); | ||
|  |   | ||
|  | -        bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_VECS));
 | ||
|  | -        if (!bio)
 | ||
|  | +        bio = bio_kmalloc(nr_vecs, gfp_mask);
 | ||
|  | +        if (!bio) {
 | ||
|  | +		pr_err("%s: bio_kmalloc failed!\n", __func__);
 | ||
|  |                  return ERR_PTR(-ENOMEM); | ||
|  | +	}
 | ||
|  | +	bio_init(bio, NULL, bio->bi_inline_vecs, nr_vecs, rw);
 | ||
|  |   | ||
|  |          while (iov_iter_count(iter)) { | ||
|  |                  struct page **pages; | ||
|  | @@ -1174,8 +1180,7 @@ static struct bio *asm_bio_map_user_iov(
 | ||
|  |                          for (j = 0; j < npages; j++) { | ||
|  |                                  struct page *page = pages[j]; | ||
|  |                                  unsigned int n = PAGE_SIZE - offs; | ||
|  | -                                /* unsigned short prev_bi_vcnt = bio->bi_vcnt;*/
 | ||
|  | -                                unsigned short prev_bi_vcnt = bio->bi_vcnt;
 | ||
|  | +                                unsigned short prev_bi_vcnt = bio->bi_vcnt; 
 | ||
|  |   | ||
|  |                                  if (n > bytes) | ||
|  |                                          n = bytes; | ||
|  | @@ -1219,7 +1224,10 @@ static struct bio *asm_bio_map_user_iov(
 | ||
|  |   | ||
|  |  out_unmap: | ||
|  |          bio_release_pages(bio, false); | ||
|  | -        bio_put(bio);
 | ||
|  | +	bio_uninit(bio);
 | ||
|  | +	bio_put(bio);
 | ||
|  | +	bio_cnt_set(bio, 0);
 | ||
|  | +        kfree(bio);
 | ||
|  |          return ERR_PTR(ret); | ||
|  |  } | ||
|  |   | ||
|  | @@ -1346,9 +1354,10 @@ static int asm_submit_io(struct file *fi
 | ||
|  |  	iov.iov_base = (void __user *)ioc->buffer_asm_ioc; | ||
|  |  	iov.iov_len = r->r_count; | ||
|  |  	iov_iter_init(&iter, rw, &iov, 1, r->r_count); | ||
|  | -	r->r_bio = asm_bio_map_user_iov(bdev_get_queue(bdev), &iter, GFP_KERNEL);
 | ||
|  | +	r->r_bio = asm_bio_map_user_iov(bdev_get_queue(bdev), &iter, GFP_KERNEL, rw);
 | ||
|  |   | ||
|  |  	if (IS_ERR(r->r_bio)) { | ||
|  | +		pr_err("%s: r_bio errored!\n", __func__);
 | ||
|  |  		ret = PTR_ERR(r->r_bio); | ||
|  |  		r->r_bio = NULL; | ||
|  |  		ret = -ENOMEM; |