The kernel block layer gets the block I/O requests from the user for the disk access.The kernel does not issue block I/O requests to the disk in the order they are received or as soon as they are received. Instead, it performs operations called merging and sorting to greatly improve the performance of the system as a whole. The subsystem of the kernel that performs these operations is called the I/O scheduler.
Kernel mainly uses below scheduling policies for disk access:
1. Complete Fair Queuing (CFQ)
Now suppose I want to get information about the current scheduling policy for one of my block device say CDROM.
As we know CDROM is represent in Linux as sr0 (can be sr1, sr2 etc. depending upon the number of same device type connected at that moment) node under /device directory.
So let me check what I/O scheduler is in for my CDROM.
noop deadline [cfq]
The bracket one tells the current I/O scheduling policy.
I can though change my current scheduling policy:
a-saurabh@a-saurabh:~$ echo deadline > /sys/block/sr0/queue/scheduler
bash: /sys/block/sr0/queue/scheduler: Permission denied
Oh, I need to be a super user to do that.
a-saurabh@a-saurabh:~$ sudo su
root@a-saurabh:/home/a-saurabh# echo deadline > /sys/block/sr0/queue/scheduler
root@a-saurabh:/home/a-saurabh# cat /sys/block/sr0/queue/scheduler
noop [deadline] cfq
So current I/O scheduling policy for my CDROM device has become deadline now.