linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boaz Harrosh <boaz@plexistor.com>
To: Ross Zwisler <ross.zwisler@linux.intel.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, Matthew Wilcox <willy@linux.intel.com>,
	Sagi Manole <sagi@plexistor.com>,
	Yigal Korman <yigal@plexistor.com>
Subject: [RFC 5/9] SQUASHME: prd: Last fixes for partitions
Date: Wed, 13 Aug 2014 15:16:09 +0300	[thread overview]
Message-ID: <53EB5709.4090401@plexistor.com> (raw)
In-Reply-To: <53EB5536.8020702@gmail.com>

From: Boaz Harrosh <boaz@plexistor.com>

This streamlines prd with the latest brd code.

In prd we do not allocate new devices dynamically on devnod
access, because we need parameterization of each device. So
the dynamic allocation in prd_init_one is removed.

Therefor prd_init_one only called from prd_prob is moved
there, now that it is small.

And other small fixes regarding partitions

Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
 drivers/block/prd.c | 47 ++++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/drivers/block/prd.c b/drivers/block/prd.c
index 62af81e..c4aeba7 100644
--- a/drivers/block/prd.c
+++ b/drivers/block/prd.c
@@ -218,13 +218,13 @@ static long prd_direct_access(struct block_device *bdev, sector_t sector,
 {
 	struct prd_device *prd = bdev->bd_disk->private_data;
 
-	if (!prd)
+	if (unlikely(!prd))
 		return -ENODEV;
 
 	*kaddr = prd_lookup_pg_addr(prd, sector);
 	*pfn = prd_lookup_pfn(prd, sector);
 
-	return size;
+	return min_t(long, size, prd->size);
 }
 
 static const struct block_device_operations prd_fops = {
@@ -279,6 +279,12 @@ static struct prd_device *prd_alloc(int i)
 	blk_queue_max_hw_sectors(prd->prd_queue, 1024);
 	blk_queue_bounce_limit(prd->prd_queue, BLK_BOUNCE_ANY);
 
+	/* This is so fdisk will align partitions on 4k, because of
+	 * direct_access API needing 4k alignment, returning a PFN
+	 */
+	blk_queue_physical_block_size(prd->prd_queue, PAGE_SIZE);
+	prd->prd_queue->limits.io_min = 512; /* Don't use the accessor */
+
 	disk = prd->prd_disk = alloc_disk(0);
 	if (!disk)
 		goto out_free_queue;
@@ -308,24 +314,6 @@ static void prd_free(struct prd_device *prd)
 	kfree(prd);
 }
 
-static struct prd_device *prd_init_one(int i)
-{
-	struct prd_device *prd;
-
-	list_for_each_entry(prd, &prd_devices, prd_list) {
-		if (prd->prd_number == i)
-			goto out;
-	}
-
-	prd = prd_alloc(i);
-	if (prd) {
-		add_disk(prd->prd_disk);
-		list_add_tail(&prd->prd_list, &prd_devices);
-	}
-out:
-	return prd;
-}
-
 static void prd_del_one(struct prd_device *prd)
 {
 	list_del(&prd->prd_list);
@@ -333,16 +321,27 @@ static void prd_del_one(struct prd_device *prd)
 	prd_free(prd);
 }
 
+/*FIXME: Actually in our driver prd_probe is never used. Can be removed */
 static struct kobject *prd_probe(dev_t dev, int *part, void *data)
 {
 	struct prd_device *prd;
 	struct kobject *kobj;
+	int number = MINOR(dev);
 
 	mutex_lock(&prd_devices_mutex);
-	prd = prd_init_one(MINOR(dev));
-	kobj = prd ? get_disk(prd->prd_disk) : NULL;
-	mutex_unlock(&prd_devices_mutex);
 
+	list_for_each_entry(prd, &prd_devices, prd_list) {
+		if (prd->prd_number == number) {
+			kobj = get_disk(prd->prd_disk);
+			goto out;
+		}
+	}
+
+	pr_err("prd: prd_probe: Unexpected parameter=%d\n", number);
+	kobj = NULL;
+
+out:
+	mutex_unlock(&prd_devices_mutex);
 	return kobj;
 }
 
@@ -424,5 +423,7 @@ static void __exit prd_exit(void)
 
 MODULE_AUTHOR("Ross Zwisler <ross.zwisler@linux.intel.com>");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("pmem");
+
 module_init(prd_init);
 module_exit(prd_exit);
-- 
1.9.3


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2014-08-13 12:16 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-13 12:08 [RFC 0/9] pmem: Support for "struct page" with Persistent Memory storage Boaz Harrosh
2014-08-13 12:10 ` [RFC 1/9] prd: Initial version of Persistent RAM Driver Boaz Harrosh
2014-08-13 12:11 ` [RFC 2/9] prd: add support for rw_page() Boaz Harrosh
2014-08-13 12:12 ` [RFC 3/9] prd: Add getgeo to block ops Boaz Harrosh
2014-08-13 12:14 ` [RFC 4/9] SQUASHME: prd: Fixs to getgeo Boaz Harrosh
2014-08-20 22:10   ` Ross Zwisler
2014-08-21  9:47     ` Boaz Harrosh
2014-08-13 12:16 ` Boaz Harrosh [this message]
2014-08-14 13:04   ` [RFC 5/9] SQUASHME: prd: Last fixes for partitions Boaz Harrosh
2014-08-14 13:16     ` Matthew Wilcox
2014-08-14 13:55       ` Boaz Harrosh
2014-08-14 13:07   ` [PATCH 5/9 v2] " Boaz Harrosh
2014-08-25 20:10     ` Ross Zwisler
2014-08-26  8:18       ` Boaz Harrosh
2014-08-26 17:36         ` Boaz Harrosh
2014-08-26 20:34           ` Ross Zwisler
2014-08-27  9:41             ` Boaz Harrosh
2014-08-27  4:38           ` Matthew Wilcox
2014-08-27  9:55             ` Boaz Harrosh
2014-08-27 12:46               ` Matthew Wilcox
2014-08-27 13:01                 ` Boaz Harrosh
2014-08-20 23:03   ` [RFC 5/9] " Ross Zwisler
2014-08-21 10:05     ` Boaz Harrosh
2014-08-13 12:18 ` [RFC 6/9] SQUASHME: prd: Let each prd-device manage private memory region Boaz Harrosh
2014-08-21 16:57   ` Ross Zwisler
2014-08-13 12:20 ` [RFC 7/9] SQUASHME: prd: Support of multiple memory regions Boaz Harrosh
2014-08-25 23:02   ` Ross Zwisler
2014-08-13 12:21 ` [RFC 8/9] mm: export sparse_add/remove_one_section Boaz Harrosh
2014-08-13 12:26 ` [RFC 9/9] prd: Add support for page struct mapping Boaz Harrosh
2014-08-15 20:28   ` Toshi Kani
2014-08-17  9:17     ` Boaz Harrosh
2014-08-18 19:48       ` Toshi Kani
2014-08-19  8:40         ` Boaz Harrosh
2014-08-19 16:49           ` Toshi Kani
2014-08-22 14:36   ` Dave Hansen
2014-09-09 16:16     ` Boaz Harrosh
2014-09-09 16:29       ` Dave Hansen
2014-08-20 20:13 ` [RFC 0/9] pmem: Support for "struct page" with Persistent Memory storage Ross Zwisler

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=53EB5709.4090401@plexistor.com \
    --to=boaz@plexistor.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=sagi@plexistor.com \
    --cc=willy@linux.intel.com \
    --cc=yigal@plexistor.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).