mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* RE: 2.6 partition support driver methods
@ 2005-08-04 12:05 Mukund JB.
  2005-08-04 14:39 ` Jonathan Corbet
  0 siblings, 1 reply; 5+ messages in thread
From: Mukund JB. @ 2005-08-04 12:05 UTC (permalink / raw)
  To: corbet; +Cc: linux-kernel

Dear corbet,

Here is the over idea about the driver status.
My driver supports 4 SD cards at a time. 
The driver works well when there are partitions are disabled.
i.e. when alloc_disk(1); - i.e. no partitions

Right now, I am working on getting the driver up with partitions
supported.
After making changes in the gendisk initialization, I am able to mount
the device in the socket 0 but I am NOT able mount the devices in the
rest of the sockets when partitions are enabled?

Also, there is nothing specific that I am implementing for partition IO
request support on the devices.

However, 
I am in bit confusion whether the following gendisk will suffice the
requirement or NOT?

Will u please verify the gendisk code below?
Here is how I am initializing the gendisk in my driver.

----------------------gendisk impl ----------------------------

	gDisk->blkqueue = blk_init_queue(do_request, &gDisk->qlock);
	if(gDisk->blkqueue == NULL) {
		printk("FM ERROR | Queue Initialization failed!\n");
		return FAILURE;
	}
	
	/* set sector size */
	blk_queue_hardsect_size(gDisk->blkqueue, DEV_SECT_SIZE);

	/* add gendisk: partitioning support.... */
	gDisk->gd = alloc_disk(4); /* 3 -> 3 partitions */
	if(! gDisk->gd) {
		printk("FM ERROR | alloc_disk failed!\n");
		return FAILURE;
	}
	gDisk->gd->major = major_num;
	gDisk->gd->first_minor = (int_of(Dev->dName[2]) *
MAX_NUM_SOCKETS) +
(iSock * 4);
	gDisk->gd->fops = &bd_op;
	gDisk->gd->private_data = Dev;

	for(i=0;i<3;i++)
		devName[i] = Dev->dName[i];
	devName[i] = char_of(iSock);
	devName[i+1] = '\0';
	strcpy(gDisk->gd->disk_name, devName);
	PRINTK("Device Name under /dev/ = %s\n", devName);

	/* removable media */
	gDisk->gd->flags |= GENHD_FL_REMOVABLE;

	set_capacity(gDisk->gd,
	((dSize * 1024)/DEV_SECT_SIZE) *
(DEV_SECT_SIZE/KRNL_SECT_SIZE));

	gDisk->gd->queue = gDisk->blkqueue;

	add_disk(gDisk->gd);
----------------------gendisk impl ENDS ----------------------------

This gendisk is invoked at socket initialization.

For example, phy devices are 
/dev/tfa0 - 3:  socket 1
/dev/tfa4 - 7:  socket 2
/dev/tfa8 - 11: socket 3
/dev/tfa12 -15: socket 4

i.e, I have created the nodes like minors 0, 1, 2, 3 for socket0
	I have created the nodes like minors 12, 13, 14, 15 for socket3.

With these physical nodes, I through it should work.
When a card is inserted in the socket 0, I am able to mount.

BUT, when a card is inserted in the socket 3, I am NOT able to mount and
it says.
Mount: /dev/tfa12 is not a valid block device

Can you convey me where exactly I am missing or why is it failing?

Regards,
Mukund Jampala


>-----Original Message-----
>From: corbet@lwn.net [mailto:corbet@lwn.net]
>Sent: Thursday, August 04, 2005 12:35 AM
>To: Mukund JB.
>Cc: linux-kernel@vger.kernel.org
>Subject: Re: 2.6 partition support driver methods
>
>> Do I need to handle any thing in the request function to handle
>> read/writes to the device partitions?
>
>It looks like you've done most of what you need; in 2.6, block drivers
>need not worry about the details of partitioning.
>
>Lots of details in the block drivers chapter of LDD3 if you need them:
>
>	http://lwn.net/Kernel/LDD3/
>
>jon
>
>Jonathan Corbet
>Executive editor, LWN.net
>corbet@lwn.net


^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: 2.6 partition support driver methods
@ 2005-08-05  5:44 Mukund JB.
  0 siblings, 0 replies; 5+ messages in thread
From: Mukund JB. @ 2005-08-05  5:44 UTC (permalink / raw)
  To: corbet; +Cc: linux-kernel

Dear Corbet,

After loading my module that is partitioned supported & having defined a
single FAT partition with 

#mkfs -tvfat /dev/tfa0

sfdisk show the disk info as follows.
# sfdisk -l /dev/taf0 

Disk /dev/tfa0: 448 cylinders, 2 heads, 32 sectors/track
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/tfa0p1          0       -       0          0    0  Empty
/dev/tfa0p2          0       -       0          0    0  Empty
/dev/tfa0p3          0       -       0          0    0  Empty
/dev/tfa0p4          0       -       0          0    0  Empty

Dear Corbet,
Here are the details u might be interested in.
I have explained my physical node creation logic below.

#Cat/proc/partitions
major minor  #blocks  name

   3     0   78184008 hda
   3     1    6144831 hda1
   3     2   10241437 hda2
   3     3    1285200 hda3
   3     4          1 hda4
   3     5   10241406 hda5
 252     0      14336 tfa0

Can you just please explain me what can infer from the cat
/proc/partitions?
Do we expect all the 4 partitions to be show here?

My node creation method is simple

Kern code
---------
gDisk->gd = alloc_disk(4); /* 3 -> 3 partitions */
gDisk->gd->first_minor = (iSock * 4);

i.e. iSock = device no [0-3] ( 4 devices)


Physical nodes design
---------------------

To support partitions on device 0
--------------------------------- 
mknod /dev/tfa0 b 252 0
mknod /dev/tfa1 b 252 1
mknod /dev/tfa2 b 252 2
mknod /dev/tfa3 b 252 3

To support partitions on device 1
---------------------------------
mknod /dev/tfa4 b 252 4
mknod /dev/tfa5 b 252 5
mknod /dev/tfa6 b 252 6
mknod /dev/tfa7 b 252 7

To support partitions on device 2
---------------------------------
mknod /dev/tfa8 b 252 8
mknod /dev/tfa9 b 252 9
mknod /dev/tfa10 b 252 10
mknod /dev/tfa11 b 252 11

To support partitions on device 3
---------------------------------
mknod /dev/tfa12 b 252 12
mknod /dev/tfa13 b 252 13
mknod /dev/tfa14 b 252 14
mknod /dev/tfa15 b 252 15


Thanks & Regards,
Mukund Jampala



>-----Original Message-----
>From: corbet@lwn.net [mailto:corbet@lwn.net]
>Sent: Thursday, August 04, 2005 8:09 PM
>To: Mukund JB.
>Cc: linux-kernel@vger.kernel.org
>Subject: Re: 2.6 partition support driver methods
>
>Mukund JB. <mukundjb@esntechnologies.co.in> wrote:
>
>> BUT, when a card is inserted in the socket 3, I am NOT able to mount
and
>> it says.
>> Mount: /dev/tfa12 is not a valid block device
>>
>> Can you convey me where exactly I am missing or why is it failing?
>
>First step would be to look in /proc/partitions (and the system
logfile)
>to get an idea of what the kernel thinks is there.  When you call
>add_disk(), the kernel should emit some messages noting the partitions
>that it sees.  My guess is a mismatch of minor numbers between your
>device nodes and what the kernel sees (it's hard for me to make
complete
>sense out of your minor number logic), but I could be wrong.
>
>jon

^ permalink raw reply	[flat|nested] 5+ messages in thread
* 2.6 partition support driver methods
@ 2005-08-03 14:23 Mukund JB.
  2005-08-03 19:05 ` Jonathan Corbet
  0 siblings, 1 reply; 5+ messages in thread
From: Mukund JB. @ 2005-08-03 14:23 UTC (permalink / raw)
  To: linux-kernel-Mailing-list

Dear all,

I have a driver implemented to support single partition in 2.6 kernels.
I have a requirement of supporting multiple partitions in my block driver to support flash media devices.
I have modified the alloc_disk(1) to alloc_dosk(16) to support a MAX of 16 partitions. This way I have conveyed it to the kernel that 16 is my max n/o partitions. I also made a call to add_disk().

Do I need to handle any thing in the request function to handle read/writes to the device partitions?
Please suggest me the required implementation that I may be missing?

Regards,
Mukund Jampala
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-08-05  5:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-04 12:05 2.6 partition support driver methods Mukund JB.
2005-08-04 14:39 ` Jonathan Corbet
  -- strict thread matches above, loose matches on Subject: below --
2005-08-05  5:44 Mukund JB.
2005-08-03 14:23 Mukund JB.
2005-08-03 19:05 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®