0

From what I understand, the disk device has a queue that stores read/write requests from the linux kernel. What happens when the device doesn't drain the queue fast enough (i.e. overflows)?

Does this queue extend (logically) into DRAM?

can some requests be lost?

Mike G
  • 4,829
  • 11
  • 47
  • 76
  • 2
    If the OS can't write to the disk device because its queue is full, it will wait and try again later. If the device never drains the queue the OS will eventually report some kind of device failure. – Barmar Aug 12 '16 at 23:11

2 Answers2

2

Does this queue extend (logically) into DRAM?

Where do you think that queue is in the first place? It's in RAM.

The IO buffering infrastructure of any operating system can only serve the purpose of avoiding blocking whatever program tries to do an IO operation.

E.g. imagine you have a program that writes data to a file. For that reason, it calls a write system call. in the Operating System, that goes to the file system driver, which decides which disk sector gets changed.

Now, that change command goes to the IO subsystem, which puts the command in a queue. If that queue is full, the file system call blocks, ie. the call doesn't complete until there is space in the queue, which means that the write call blocks.

very simple: for as long as your writing device doesn't keep up, your writing program gets stopped in the write call. That's pretty logical. It's like trying to push mail into a full postbox. Until someone takes out the mail at the other end, you can't push in new mail, so the postman will have to wait.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • The first line in your answer doesn't seem correct. The disk device will reschedule read/write requests to optimize head movement. If whole queue is in ram, then how is the disk inspecting the queue which you claim resides in ram? – Mike G Aug 12 '16 at 23:34
  • @MikeG I think you have a specific type of device in mind that actually has that capability of rearranging access in the device's own memory, is that possible? I was assuming we're reading about software queues, because you never mention which device. – Marcus Müller Aug 13 '16 at 08:21
0

The queue doesn't extend to RAM. There's a disk cache with dirty pages. The OS really would like to write those to disk. Some programs may even block while they're waiting for their dirty pages to be written. And as programs get blocked, they stop writing further data to disk. Pretty self-limiting, actually.

MSalters
  • 173,980
  • 10
  • 155
  • 350