Magnetic disk drive
The magnetic disk device uses a B+ tree database to efficiently select the next command based on proximity to the current access point, addressing inefficiencies in command reordering and enhancing operating speed and data integrity.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2026-03-25
AI Technical Summary
Existing magnetic disk devices face inefficiencies in data writing and reading operations, particularly in the reordering of commands to improve operating speed, due to time-consuming searches for optimal command execution.
A magnetic disk device employing a tree-structured database with nodes associated with command addresses, allowing efficient selection of the next command to be executed based on proximity to the current access point, using a B+ tree structure to manage command queues.
Enhances the speed of command execution by quickly identifying the most efficient next command, ensuring data integrity and reducing search time, thereby improving overall device performance.
Smart Images

Figure 2026052879000001_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to a magnetic disk device.
Background Art
[0002] Examples of magnetic disk devices include HDDs (Hard Disk Drives). A magnetic disk device receives commands from the outside even while writing data to and reading data from a magnetic disk. The received commands can be managed using a queue, that is, managed in the order in which the commands are received, from the viewpoint of maintaining data integrity.
[0003] On the other hand, in order to improve the operating speed of a magnetic disk device, it is required that data writing and reading be performed efficiently. For that purpose, there is a technique in which a command instructing access to a region closer to the currently accessed region on a magnetic disk is selected as the next command to be executed. Such a technique is called reordering. In order to perform reordering, commands in the queue are searched. Searching for commands can take time.
Prior Art Documents
Patent Documents
[0004]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0005] Provided is a magnetic disk device that can search commands efficiently.
Means for Solving the Problems
[0006] A magnetic disk device according to one embodiment includes a magnetic disk, memory, and a controller. The magnetic disk includes a plurality of areas, each with a unique address. The memory stores a plurality of pending commands. The controller stores a tree-structured database in the memory. The structure includes a plurality of nodes, each associated with a plurality of addresses specified by each of the plurality of pending commands, and two of the plurality of nodes are associated with each other. The controller selects a candidate command to be executed next from among the plurality of pending commands, from commands associated with an address greater than the start address and closest to the start address, and commands associated with an address less than the start address and closest to the start address. [Brief explanation of the drawing]
[0007] [Figure 1] Figure 1 shows the hardware configuration of a magnetic disk device according to the first embodiment. [Figure 2] Figure 2 shows an example of the area of the magnetic disk in a magnetic disk device according to the first embodiment. [Figure 3] Figure 3 shows an example of the address of a region of the magnetic disk in a magnetic disk device according to the first embodiment. [Figure 4] Figure 4 shows the functional configuration of the magnetic disk device according to the first embodiment. [Figure 5] Figure 5 shows an example of a data structure used in a magnetic disk device according to the first embodiment. [Figure 6] Figure 6 shows an example of one state of the database in a magnetic disk device according to the first embodiment. [Figure 7] Figure 7 shows an example of one state of the database in a magnetic disk device according to the first embodiment. [Figure 8] Figure 8 shows an example of one state of the database in a magnetic disk device according to the first embodiment. [Figure 9]Figure 9 shows a flowchart of a certain operation in a magnetic disk device according to the first embodiment. [Figure 10] Figure 10 shows a flowchart of a certain operation in a magnetic disk device according to the first embodiment. [Figure 11] Figure 11 shows an example of the execution cost at a certain point in time in a magnetic disk device according to the first embodiment. [Figure 12] Figure 12 shows the functional configuration of a magnetic disk device according to the second embodiment. [Figure 13] Figure 13 shows an example of data obtained in a magnetic disk device according to the second embodiment. [Figure 14] Figure 14 shows an example of a filter used in a magnetic disk device according to the second embodiment. [Figure 15] Figure 15 shows an example of data obtained in a magnetic disk device according to the second embodiment. [Figure 16] Figure 16 shows a flowchart of an operation of a magnetic disk device according to the second embodiment. [Figure 17] Figure 17 shows a flowchart of an operation in a magnetic disk device according to the second embodiment. [Modes for carrying out the invention]
[0008] Embodiments are described below with reference to the drawings. In embodiments following a previously described embodiment, the differences from the previously described embodiment are primarily described. All descriptions of an embodiment also apply to other embodiments unless explicitly or obviously excluded.
[0009] 1. First Embodiment FIG. 1 shows the hardware configuration of a magnetic disk drive according to the first embodiment. The magnetic disk drive 1 is a device that stores data based on the magnetization of a magnetic material. The magnetic disk drive 1 communicates with the host device 2 via a communication method based on an arbitrary standard. Examples of the host device 2 include a personal computer. The magnetic disk drive 1 is connected to the host device 2 via wiring based on the communication method followed by the magnetic disk drive. Examples of the communication method include SATA (Serial Advanced Technology Attachment). The magnetic disk drive 1 receives commands from the host device 2 and operates based on the commands. The magnetic disk drive 1 stores the data supplied from the host device 2 based on the commands. Also, the magnetic disk drive 1 transmits the data stored in the magnetic disk drive 1 to the host device 2 based on the commands.
[0010] As shown in FIG. 1, the magnetic disk drive 1 includes components such as a magnetic disk 11, a spindle motor 12, an arm 13, a magnetic head 14, a voice coil motor 15, a motor driver 16, a head amplifier 17, a RW channel 18, a CPU 21, a ROM 22, a RAM 23, a buffer memory 24, and an HDD controller 25.
[0011] The magnetic disk 11 is a disk-shaped storage medium that stores data. The magnetic disk 11 uses a magnetic material to store data on the recording surface. The magnetic disk drive 1 may include two or more magnetic disks 11.
[0012] The spindle motor 12 is a device that rotates the magnetic disk 11. The spindle motor 12 has a rotation shaft and a drive unit. The spindle motor 12 holds the magnetic disk 11 by the rotation shaft. The rotation shaft is connected to the center of the magnetic disk 11, and the magnetic disk 11 rotates around the rotation shaft due to the rotation of the rotation shaft. The drive unit drives the rotation shaft to rotate the rotation shaft.
[0013] The arm 13 is a component that holds the magnetic head 14. The arm 13 has a rod-like shape and holds the magnetic head 14 at its tip.
[0014] The magnetic head 14 is a component for writing data to and reading data from the magnetic disk 11. The magnetic head 14 is attached to the tip of the arm. The magnetic head 14 contains a magnetic material. The magnetic head 14 is positioned slightly away from the recording surface of the magnetic disk 11 by the arm 13. The magnetic head 14 includes a write element 14w and a read element 14r.
[0015] The write element 14w writes write data by changing the magnetization state of the area on the magnetic disk 11 where data is to be written. The write data is the data to be stored in the area to be written. The write element 14w receives a write current and changes the magnetization of the area to be written based on the write current.
[0016] The read element 14r generates a read signal based on the data stored in the area to be read, based on the magnetization state of the read element 14r and the magnetization state of the area on the magnetic disk 11 where data is to be read.
[0017] The voice coil motor 15 is a motor that mechanically drives an object to be driven by the voice coil motor 15 based on an electrical signal. The voice coil motor 15 moves the arm 13 along the radial direction of the magnetic disk 11. The radial direction is the direction along the radius of the magnetic disk 11.
[0018] The motor driver 16 is a circuit that controls the drive of the spindle motor 12 and the drive of the voice coil motor 15. The motor driver 16 receives electrical signals and generates control signals based on the received electrical signals. The generated control signals include information for controlling the drive of the spindle motor 12 and information for controlling the drive of the voice coil motor 15. The motor driver 16 is controlled by a CPU 21 that executes a program. In one example, the motor driver 16 has the form of an integrated circuit (IC) chip.
[0019] The head amplifier 17 is a circuit that performs processing for writing data to and reading data from the magnetic disk 11. The head amplifier 17 includes a read amplifier and a write driver. The read amplifier receives a read signal from the read element 14r and amplifies the read signal. The write driver receives a signal based on the write data stored in the magnetic disk 11 and generates a write current based on the received signal. The write current is supplied to the write element 14w. In one example, the head amplifier 17 has the form of an IC chip.
[0020] The RW channel 18 is a circuit that processes signals. The RW channel 18 receives write data from the HDD controller 25 or buffer memory 24, modulates (or converts to analog format) the write data, and generates a signal based on the write data. The RW channel 18 supplies the generated signal to the write driver of the head amplifier 17. The RW channel 18 receives an amplified read signal from the head amplifier 17. The RW channel 18 demodulates (or converts to digital format) the received read signal to generate read data. The read data is supplied to the HDD controller 25 or buffer memory 24.
[0021] The CPU 21 is an integrated circuit capable of executing various programs. The CPU 21 controls and executes the overall operation of the magnetic disk drive 1 through program execution. The magnetic disk drive 1 performs various operations and functions as various functional blocks, as described later, through the execution of programs (or firmware) stored in the ROM 22 and loaded onto the RAM 23 by the CPU 21. Furthermore, the CPU 21 controls the motor driver 16 and the head amplifier 17 through the execution of programs stored in the ROM 22 and on the RAM 23.
[0022] ROM22 is a non-volatile memory that stores programs (or firmware) and control data for implementing some of the functions of the magnetic disk drive 1 and for controlling the magnetic disk drive 1.
[0023] RAM23 is volatile memory that temporarily stores data. RAM23 also functions as a workspace for the CPU21. Examples of RAM23 include DRAM (Dynamic Random Access Memory) and SRAM (Static Random Access Memory).
[0024] The buffer memory 24 is a semiconductor memory that temporarily stores data and commands transmitted and received between the magnetic disk device 1 and the host device 2. Examples of buffer memory 24 include DRAM and SRAM. The buffer memory 24 and RAM 23 may be integrated. That is, a portion of the storage area of RAM 23 may be used as buffer memory 24. The buffer memory 24 includes an area that functions as a command queue 241.
[0025] Command queue 241 temporarily stores commands received by the magnetic disk drive 1 from the host device 2. Command queue 241 outputs the commands received by the magnetic disk drive 1 in the order they were received. Commands include write commands and read commands. A write command specifies the area of the magnetic disk 11 where data will be written, by its starting address and size. Based on a read command, the magnetic disk drive 1 sends the data stored in the magnetic disk drive 1 to the host device 2. A read command specifies the area of the magnetic disk 11 where data will be read, by its starting address and size. Commands stored in command queue 241 are unprocessed (or not executed) commands, and may hereafter be referred to as unprocessed commands.
[0026] The HDD controller 25 is an interface that controls the transmission and reception of signals between the magnetic disk drive 1 and the host device 2. The HDD controller 25 includes circuits and terminals (or connectors) for connection to wiring that enables communication with the host device 2. The HDD controller 25 supplies write data received from the host device 2 to the buffer memory 24 and / or RAM 23. The HDD controller 25 receives read data from the buffer memory 24 and / or RAM 23 and transmits the read data to the host device 2. The HDD controller 25 supplies commands received from the host device 2 to the buffer memory 24. Some of the functions of the HDD controller 25 may be realized by the execution of a program loaded on RAM 23 by the CPU 21.
[0027] Figure 2 shows an example of the area of the magnetic disk of a magnetic disk device according to the first embodiment. As shown in Figure 2, the recording surface of the magnetic disk 11 includes a plurality of tracks TR. Figure 2 shows an example of six tracks TR, namely tracks TR_1, TR_2, TR_3, TR_4, TR_5, and TR_6. The tracks TR are wheels with different radii. The centers of the tracks TR are common. In the example in Figure 2, tracks TR_1, TR_2, TR_3, TR_4, TR_5, and TR_6 are located in this order, further from the center. Two tracks TR are adjacent to each other.
[0028] In one example, the magnetic disk 11 rotates in a clockwise direction, one of two directions along its circumference. The rotation of the magnetic disk 11 causes the magnetic head 14 to move relative to the magnetic disk 11. The direction in which the magnetic disk 11 rotates is sometimes referred to as the rotational direction.
[0029] Figure 3 shows an example of the addresses of the magnetic disk area in a magnetic disk device according to the first embodiment. As shown in Figure 3, each track TR is further divided into multiple unit areas UA. Each unit area UA can store data of the same size. An example of a unit area UA is one or more sectors. Each unit area UA is assigned a unique address. An example of an address is an LBA (Logical Block Address). In one example, in each track TR, addresses are assigned in ascending order to the unit areas UA arranged in the rotational direction. That is, in the example in Figure 3, the unit areas UA arranged in the rotational direction of track TR_1 have addresses that are 0 or greater and n or less, with addresses having larger values in this order. n is a positive integer. The unit areas UA arranged in the rotational direction of track TR_2 have addresses that are n+1 or greater and m or less, with addresses having larger values in this order. m is a positive integer greater than n+1. The same applies to other track TRs such as track TR_3. In Figure 3, the servo area is omitted. The servo region is an area that extends radially from the center of the magnetic disk 11 and is used for aligning the magnetic head 14 with respect to the magnetic disk 11, but is not used for storing data.
[0030] Figure 4 shows the functional configuration (functional blocks) of a magnetic disk device according to the first embodiment. While operating, the magnetic disk device 1 has functions that are performed by the functional blocks shown in Figure 4 and described below. It is not essential that each functional block in each embodiment is distinguished as in the following example. Some functions may be performed by functional blocks other than the illustrative functional blocks, or they may be divided into finer functional subblocks.
[0031] As shown in Figure 4, the magnetic disk drive 1 includes a motor driver 16, a head amplifier 17, an RW channel 18, an HDD controller 25, an RW control unit 31, a database 32, a database operation unit 33, a command search unit 34, and a command selection unit 35. In one example, the database 32 is implemented by the memory space of RAM 23. In another example, the database operation unit 33, the command search unit 34, and the command selection unit 35 are implemented by a program loaded from ROM 22 onto RAM 23 and executed by the CPU 21.
[0032] The RW control unit 31 is a functional block that controls the entire process of reading and writing data in the magnetic disk drive 1. The RW control unit 31 controls the motor driver 16 and the head amplifier 17 based on the read or write command being executed. The RW control unit 31 controls the RW channel 18 based on the read or write command. The RW control unit 31 also controls the reordering process. That is, the RW control unit 31 selects an unprocessed command from among the unprocessed commands stored in the command queue 241 that is considered to be the most efficient to execute next, and executes this unprocessed command. Details of the selection of unprocessed commands will be described later. The RW control unit 31 starts the reordering process under arbitrary conditions based on the program.
[0033] Database 32 is management data for managing unprocessed commands in command queue 241.
[0034] The database operation unit 33 is a functional block that operates and updates the database based on the addition and deletion of commands to and from the command queue 241. When an unprocessed command is added to the command queue 241, the database operation unit 33 adds data about the added unprocessed command to the database 32. When an unprocessed command is removed from the command queue 241 as a result of being executed, the database operation unit 33 deletes data about the deleted command from the database 32.
[0035] The command search unit 34 is a functional block that uses the database 32 to search for unprocessed commands that meet certain conditions. The command search unit 34 receives a command selection request from the RW control unit 31. The command selection request asks for the selection of unprocessed commands based on certain conditions. The command search unit 34 outputs the unprocessed commands found based on the specified conditions as candidate commands from the command queue 241.
[0036] The command selection unit 35 is a functional block that selects the command to be executed after the currently executing command. Hereinafter, the command to be executed after the currently executing command may be referred to as the next command. The command selection unit 35 receives candidate commands. The command selection unit 35 compares the candidate commands with the current next command and selects the latest next command based on the result of the comparison. The latest next command is received by the RW control unit 31. When the RW control unit 31 becomes ready to execute a new unprocessed command, it executes the current next command.
[0037] One, multiple, or all of the following can be considered a control unit or controller: the HDD controller 25, the RW control unit 31, the database operation unit 33, the command search unit 34, and the command selection unit 35.
[0038] Figure 5 shows an example of a data structure used in a magnetic disk device according to the first embodiment. The data in database 32 is structured in an extended form of a B+ tree. A B+ tree is a data structure widely used in the field of databases. Figure 5 shows an example of the data structure in database 32.
[0039] In database 32, multiple nodes are structured in the form of a tree (or hierarchy). Node types include leaf nodes NL and parent nodes NP. Leaf nodes NL are nodes that can be associated with unprocessed commands CMD. Parent nodes NP are nodes that are not associated with unprocessed commands CMD and are located higher up than leaf nodes NL. Parent nodes NP can span two or more layers.
[0040] Each parent node NP contains one or more keys K and two branches BR associated with one key K. The two branches BR are shown in the diagram as being to the lower left and lower right of the associated key K. Branches BR may contain pointers P. The lower left pointer P of two pointers P associated with a key K of a parent node NP has a value that refers to a parent node NP or leaf node NL containing a key K with a value less than the value of this key K. The lower right pointer P of two pointers P associated with a key K of a parent node NP has a value that refers to a parent node NP or leaf node NL containing a key K with a value greater than or equal to the value of this key K. If a parent node NP contains two keys K, the lower right pointer P of the key K with the smaller value and the lower left pointer P of the key K with the larger value are common.
[0041] In the example in Figure 5, the lower left branch BR of the key K "33" associated with the parent node NP_1 contains pointer P_1. Pointer P_1 refers to the parent node NP_2 which contains key K with a value less than "33". The lower right branch BR of the key K "33" associated with the key K "33" contains pointer P_2. Pointer P_2 refers to the parent node NP_3 which contains key K with a value greater than or equal to "33". In the example in Figure 5, the parent node NP_2 contains key K "10" and key K "27", and the parent node NP_3 contains key K "40".
[0042] A leaf node NL further contains key KEs. Each leaf node NL contains the same number of key KEs as the number of key Ks. Each key KE is associated with one key K and one branch BR. Branch BR may contain a pointer P that refers to one unprocessed command CMD, and thus may be associated with one unprocessed command CMD. Thus, in a leaf node NL, one key KE, one key K, and one pointer P (and by extension, the unprocessed command CMD referred to by pointer P) are associated with each other. Each key K has as its value the start address specified by the unprocessed command CMD associated with that key K. Each key KE has as its value the end address specified by the unprocessed command CMD associated with that key KE. The end address of a command is the address of the unit region UA that contains the end of the region specified by that command. As described above, a command CMD specifies the region to be processed by its start address and size. Therefore, the end address can be determined from the start address and size.
[0043] In the example in Figure 5, the keys K and KE of "10" are associated with the unprocessed command CMD2 by pointer P_3. The keys K and KE of "27" are associated with the unprocessed command CMD3. The keys K and KE of "33" are associated with the unprocessed command CMD4. The keys K and KE of "40" are associated with the unprocessed command CMD5.
[0044] Each leaf node NL is associated with one or two other leaf nodes NL by a pointer Pb. More specifically, a first leaf node NL is associated by a pointer Pb with a second leaf node NL that contains the smallest value key K, which is greater than or equal to the maximum value key K contained in the first leaf node NL. Also, the first leaf node NL is associated by a pointer Pb with a second leaf node NL that contains the largest value key, which is less than the smallest value key K contained in the first leaf node NL.
[0045] The branch BR of a leaf node NL may contain a pointer P that references an extension node NE. An extension node NE is created along with the pointer P when a command specifying an address within the range greater than or equal to the value of key K and less than or equal to the value of key KE is received by the magnetic disk device 1, while a leaf node NL containing a certain key K and key KE exists. In other words, an extension node NE referenced by a leaf node NL is created chronologically later than the leaf node NL. In the example in Figure 5, the leaf node NL_1 contains a pointer P_4 to an extension node NE_1.
[0046] An extended node NE contains a pointer P to a leaf node NL that references this extended node NE, containing a key K whose value falls within the range of greater than or equal to the value of key K and less than or equal to the value of key KE. In the example in Figure 5, extended node NE_1 contains a pointer P_5 to leaf node NL_2. Leaf node NL_2 contains a key K of "0" and a key KE of "3", as well as a pointer to an unprocessed command CMD1 specifying addresses from "0" to "3". In the example in Figure 5, extended node NE_1 further contains a pointer P_6 to leaf node NL_3. Leaf node NL_3 contains a key K of "5" and a key KE of "7", as well as a pointer to an unprocessed command CMD6 specifying addresses from "5" to "7". Leaf node NL_3 further contains a key K of "8" and a key KE of "9", as well as a pointer to an unprocessed command CMD7 specifying addresses from "8" to "9".
[0047] As described above, an extension node NE referenced by a first leaf node NL is created after the first leaf node NL is created. Then, a second leaf node NL referenced by an extension node NE is created together with the extension node NE, or after the extension node NE is created. Therefore, the unprocessed command CMD associated with the second leaf node NL referenced by the extension node NE is received after the unprocessed command CMD associated with the first leaf node NL that references the extension node NE.
[0048] When a leaf node NL exists that is referenced by an extension node NE and contains keys K and KE, and the magnetic disk device 1 receives a command specifying an address within the range greater than or equal to the value of key K and less than or equal to the value of key KE, a further extension node NE is created along with a pointer P. In the example in Figure 5, when a leaf node NL_2 containing key K of "0" and key KE of "3" and a leaf node NL_3 containing key K of "5" and key KE of "7" exist, an unprocessed command CMD8 specifying a start address "4" and a end address "5" is received. Therefore, based on the receipt of the unprocessed command CMD8, an extension node NE_2 referenced by extension node NE_1 is created. Extension node NE_2 references leaf node NL_4 by pointer P_7. Leaf node NL_4 contains key K of "4" and key KE of "5". The key K of leaf node NL_4 contains a pointer to command CMD8 specifying a start address "4" and an end address "5".
[0049] As described above, an unprocessed command associated with a leaf node NL referenced by a second extension node NE, which in turn is referenced by a first extension node NE (e.g., unprocessed command CMD8), is received after an unprocessed command associated with a leaf node NL referenced by the extension node NE (e.g., unprocessed commands CMD6 and CMD7).
[0050] When a further command CMD is received by the magnetic disk device 1 while there are unprocessed command CMDs stored in the command queue 241, the B+ tree of the database 32 is modified by the database operation unit 33. If the received command CMD specifies an address that does not partially overlap with the address specified by the unprocessed command CMD associated with the leaf node NL, the leaf node NL is added. Adding a leaf node NL is the same as adding a leaf node NL in a typical B+ tree.
[0051] When an unprocessed command CMD stored in command queue 241 is executed, the B+ tree in database 32 is modified by the database operation unit 33. If the executed command CMD is associated with a leaf node NL that is not associated with an extension node NE, this leaf node NL is deleted. The deletion of leaf node NL is the same as the deletion of a leaf node NL in a typical B+ tree.
[0052] Next, with reference to Figures 5 to 7, an example of adding leaf nodes NL and extension nodes NE in the magnetic disk device 1 is described. Figures 6 and 7 show an example of one state of the database in the magnetic disk device according to the first embodiment.
[0053] Figure 6 shows the state prior to the state shown in Figure 5, differing from Figure 5 in that leaf nodes NL_2, NL3, and NL4 have not been created, and leaf node NL_1 is absent. Specifically, leaf node NL_1 is associated with an unprocessed command CMD1 that includes key K of “0” and key KE of “3” and specifies start address “0” and end address “3”. Assume that in the state shown in Figure 6, commands CMD6 and CMD7 are stored in command queue 241. As described above with reference to Figure 5, unprocessed command CMD6 specifies start address “5” and end address “7”, and unprocessed command CMD7 specifies start address “8” and end address “9”. Part of the specified address ranges at least partially overlaps with the range from the start address represented by key K to the end address represented by key KE of leaf node NL_1. Based on this, database 32 is changed to the state shown in Figure 7.
[0054] Specifically, a pointer P_4 is created in leaf node NL_1, which is associated with the address range specified by the unprocessed commands CMD6 and CMD7, and the unprocessed command CMD1, which specifies a partial address range. Pointer P_4 refers to the extension node NE_1. A pointer P_5 is also created in the extension node NE_1, and a leaf node NL_2 is created, which is referenced by pointer P_5. Furthermore, a pointer P_6 is created from the extension node NE_1, and a leaf node NL_3 is created, which is referenced by pointer P_6. As shown above with reference to Figure 5, leaf node NL_2 contains the key K of "0", the key KE of "3", and a pointer to the unprocessed command CMD1, which specifies the start address "0" and the end address "3". Leaf node NL_3 contains the key K of "5", the key KE of "7", and a pointer to the unprocessed command CMD6, which specifies the end address "5" and the end address "7". The leaf node NL3 further includes key K for “8”, key KE for “9”, and a pointer to an unprocessed command CMD6 specifying the start address “8” and the end address “9”.
[0055] Assume that command CMD8 is stored in command queue 241 in the state shown in Figure 6. As described above with reference to Figure 5, the unprocessed command CMD8 specifies a start address "4" and a end address "5". Part of the specified address range overlaps at least partially with the range from the start address represented by key K to the end address represented by key KE of leaf node NL_1. Furthermore, part of the specified address range overlaps at least partially with the range from the start address represented by key K to the end address represented by key KE of leaf node NL_3. Based on this, database 32 is changed to the state shown in Figure 5.
[0056] In other words, an extended node NE_2 is created, which is referenced by a pointer from an extended node NE_1 that references a leaf node NL_1 associated with an unprocessed command CMD1 that specifies an address range that partially overlaps with the address range specified by the unprocessed command CMD8. Furthermore, a pointer P_7 is created in the extended node NE_2, and a leaf node NL_4 is created, which is referenced by pointer P_7. As shown above with reference to Figure 5, the leaf node NL_4 contains the key K for "4", the key KE for "5", and a pointer to the unprocessed command CMD8 that specifies the start address "4" and the end address "5".
[0057] Commands are executed in priority from those associated with higher-level leaf nodes (NL). Therefore, even if two or more unprocessed command CMDs specifying the same start address are stored in command queue 241, the unprocessed command CMD received first is guaranteed to be executed first. In other words, in the example in Figure 5, address "5" is specified by both unprocessed command CMD6 and CMD8. However, the unprocessed command CMD associated with the higher-level leaf node (NL) is executed first. In the example in Figure 5, unprocessed command CMD CMD6 is executed before unprocessed command CMD8. This ensures that even if command CMDs specifying the same address are received consecutively, these command CMDs can be executed in the order they were received. This ensures data integrity.
[0058] Referring to Figures 8 and 6, an example of deleting leaf nodes NL and extension nodes NE in magnetic disk device 1 is described. Figure 8 shows an example of one state of the database in magnetic disk device according to the first embodiment.
[0059] Figure 8 shows the state continuing from Figure 5. In the state shown in Figure 5, when the unprocessed command CMD1 is executed, the leaf node NL_2 is deleted, and the pointer P_5 is changed to refer to the leaf node NL_3. In the state shown in Figure 5, when the unprocessed command CMD6 or CMD7 is executed, the key K, key KE, and pointer P associated with the executed unprocessed command CMD are deleted. The leaf node NL_3 is further deleted when the unprocessed command CMD7 is executed after the execution of the unprocessed command CMD6, or when the unprocessed command CMD6 is executed after the execution of the unprocessed command CMD7.
[0060] Suppose the unprocessed commands CMD1, CMD6, and CMD7 are executed in any order from the state shown in Figure 5. Then, leaf nodes NL_2 and NL_3 are deleted. When the latter of the two leaf nodes NL_2 and NL_3 is deleted, there are no more leaf nodes NL referenced by extension node NE_1. Based on this, all leaf nodes NL below extension node NE_1 are moved to the layer above. That is, in the example in Figure 8, leaf node NL_4 is moved to the layer referenced by extension node NE_1. Specifically, pointer P_5 is changed to refer to leaf node NL_4. Furthermore, this change eliminates leaf node NL_4 being referenced by extension node NE_2. Based on this, extension node NE_2 is deleted. Specifically, when the unprocessed command CMD8 is executed from the state shown in Figure 8, extension node NE_1 and leaf node NL_4 are deleted as shown in Figure 6.
[0061] Figure 9 shows a flow of a certain operation in a magnetic disk device according to the first embodiment. The flow in Figure 9 begins when the RW control unit 31 starts processing to determine the command that is considered efficient to execute after the currently executing command, as part of the reordering process. More specifically, the flow in Figure 9 begins when the RW control unit 31 sends a command selection request to the command search unit 34 as part of the reordering process.
[0062] As shown in Figure 9, when the command search unit 34 receives a command selection request, it selects a candidate command (step ST1). The candidate command is an unprocessed command that is compared with the current (or provisional) next command in order to determine the next command that will lead to more efficient execution. Details of the selection of candidate commands will be described later with reference to Figure 10. The candidate command is received by the command selection unit 35.
[0063] When the command selection unit 35 receives a candidate command, it compares the execution cost of the current next command with the execution cost of the candidate command. The execution cost can be calculated using any method. An example of the execution cost is the time required to move from the current position of the magnetic head 14 to the start address specified by the command for which the execution cost is to be calculated. The shorter the time, the lower the execution cost. A detailed example of the execution cost calculation will be described later with reference to Figure 11. If the execution cost of the next command is less than the execution cost of the candidate command (step ST2_No), the command selection unit 35 continues to select the current next command as the next command (step ST3).
[0064] If the execution cost of the next command is greater than the execution cost of the candidate command (step ST2_Yes), the command selection unit 35 selects the candidate command as the new (or latest) next command (step ST4).
[0065] The flow shown in Figure 9 may be repeated while the reordering process is in progress. The next command at the end of the reordering process is executed when the magnetic disk device 1 is ready to execute a new unprocessed command.
[0066] Figure 10 shows a flow of a certain operation in a magnetic disk device according to the first embodiment. Specifically, Figure 10 shows a subflow of the selection of candidate commands in Figure 9 (step ST1).
[0067] As shown in Figure 10, the command search unit 34 searches the database 32 for a key K with a value closest to the address where the magnetic head 14 is currently located on the magnetic disk 11 (step ST11). The value of the found key Ks_c serves as the starting position for the candidate command search (search start position).
[0068] The command search unit 34 searches the database 32 for the smallest value of key Ks_c that is greater than the value of key Ks_c (the value closest to key Ks_c) (step ST12). Step ST12 is equivalent to searching for the address closest to the address of the value of key Ks_c by searching for addresses in ascending order of addresses starting from the address of the value of key Ks_c. The discovered key K is called key Ks_L.
[0069] The command search unit 34 calculates the difference D_L between the value of key Ks_c and the value of key Ks_L (step ST13).
[0070] The command search unit 34 searches the database 32 for the maximum value of key Ks_c that is smaller than the value of key Ks_c (the value closest to key Ks_c) (step ST14). Step ST14 is equivalent to searching for the address closest to the address of the value of key Ks_c by searching for addresses in descending order of addresses starting from the address of the value of key Ks_c. The discovered key K is called key Ks_S.
[0071] The command search unit 34 calculates the difference D_S between the value of key Ks_c and the value of key Ks_S (step ST15).
[0072] Steps ST12, ST13, ST14, and ST15 can be performed in any order, as long as step ST13 is performed after step ST12 and step ST15 is performed after step ST14. In one example, the pair of steps ST14 and ST15 is performed before the pair of steps ST12 and ST13. In another example, the pair of steps ST14 and ST15 is performed after the pair of steps ST12 and ST14 has been performed (either step ST12 or ST14 may be performed first) (either step ST13 or ST15 may be performed first).
[0073] The command search unit 34, if the difference D_L is smaller than the difference D_S (step ST16_Yes), selects an unprocessed command that specifies the value of key Ks_L as the starting address as a candidate command (step ST17). When step ST17 is completed, the flow in Figure 10 ends.
[0074] The command search unit 34, if the difference D_S is greater than the difference D_L (step ST16_Yes), selects an unprocessed command that specifies the value of key Ks_S as the starting address as a candidate command (step ST19). When step ST17 is completed, the flow in Figure 10 ends.
[0075] If the difference D_S and the difference D_L are the same, either step ST17 or ST18 may be performed.
[0076] Figure 11 shows an example of the execution cost at a certain point in time in a magnetic disk device according to the first embodiment. As shown in Figure 11, assume that the magnetic head 14 of the magnetic disk 11 is currently located at address A. Address A is an area within the outermost track TR_1. The next command at this stage is an unprocessed command C, and the unprocessed command C specifies address C. Address C is an area within track TR_1. Address C is located at a distance from address A that is shorter than the distance along the counter-rotation direction of the magnetic disk 11 along the rotation direction. The counter-rotation direction is opposite to the rotation direction.
[0077] Suppose an unprocessed command B is determined to be a candidate command. Unprocessed command B specifies address B. Address B is an area within track TR_2, which is adjacent to track TR_1, inside track TR_1. Based on the positions of address B and address C, the command selection unit 35 determines that the cost (execution cost) of the magnetic head 14 moving from its current position to address C is less than the cost of the magnetic head 14 moving from its current position to address B. Therefore, the command selection unit 35 determines that unprocessed command C remains the next command.
[0078] Next, let's assume that an unprocessed command T is determined as a candidate command. The unprocessed command T specifies address T. Address T is an area within track TR_2, and is an area within track TR_2 that is very close to the area adjacent to address A. Based on the positions of address C and address T, the command selection unit 35 determines that the cost of moving the magnetic head 14 from its current position to address T is less than the cost of moving the magnetic head 14 from its current position to address C. Therefore, the command selection unit 35 selects the unprocessed command T as the new next command.
[0079] According to the first embodiment, a magnetic disk device capable of high-speed operation is provided, as described below.
[0080] Commands received by the magnetic disk drive 1 can be stored in a queue, that is, accumulated as a linear list. In this case, when searching for unprocessed commands as part of the reordering process, the search is performed in the order of the unprocessed commands (i.e., the order in which they were received). Therefore, even if an optimal unprocessed command is found in the early stages of the search, it is not possible to know whether the found unprocessed command is truly optimal until the entire linear list has been searched. For this reason, finding the truly optimal unprocessed command can take a long time. If the search attempts to search all unprocessed commands along the linear list, the time allocated for the search may run out midway through the search. In this case, the optimal unprocessed command will not be found.
[0081] The magnetic disk drive 1 manages unprocessed commands using a B+ tree structure that uses the value of the starting address specified by the unprocessed command as key K. The B+ tree allows nodes to be searched in the order of their key K values (i.e., starting addresses), both in the forward and reverse directions of key K. To select a candidate for the next command, the search begins from the starting address closest to the current address of the magnetic head 14, and the search proceeds both forward and reverse directions. Between the starting address closest to the forward direction and the starting address closest to the reverse direction, the closer one is selected as the candidate command. Therefore, even in a short time, a candidate command specifying the address closest to the current position of the magnetic head 14 can be found.
[0082] 2. Second Embodiment The second embodiment can be implemented in addition to the first embodiment, or it can be implemented independently of the first embodiment.
[0083] Figure 12 shows the functional configuration (functional block) of a magnetic disk device according to the second embodiment. As shown in Figure 12, the magnetic disk device 1 further includes a command address analysis unit 37. The command address analysis unit 37 can be considered as part of the control unit.
[0084] The command address analysis unit 37 determines the starting position for the next reordering process based on the density of addresses specified by the commands. The command address analysis unit 37 stores the command address distribution (command address distribution data). The command address distribution shows the number of received commands that specify each address specified by commands received so far by the magnetic disk device 1. In one example, the received commands are write commands and read commands received from the time the magnetic disk device 1 started operating after receiving power. Figure 13 shows an example of a command address distribution. The value A in the figure has an arbitrary size.
[0085] The command address analysis unit 37 stores the range of addresses searched during a certain reordering process. That is, during the reordering process, candidate commands for the next command are repeatedly searched for, starting from the address closest to the address where the current magnetic head 14 is located. The execution cost of the discovered candidate commands is then compared with the execution cost of the current next command. The command address analysis unit 37 stores the addresses specified by the candidate commands whose execution costs have been compared with the execution cost of the next command. As a result, when the reordering process is completed, the address range of candidate commands discovered during this reordering process can be determined.
[0086] The command address analysis unit 37 calculates the density of received commands within the address range of candidate commands (command density) from the command address distribution at the end of a certain reordering process. A low command density indicates that there are few received commands within the address range specified by the candidate commands discovered in the most recent reordering process. In the example in Figure 13, during a certain reordering process, candidate commands were discovered across the address range enclosed by the dashed line, and so far there have been 24A received commands specifying addresses within that address range. The command density in this address range is lower than the baseline value. Based on this, the command address analysis unit 37 decides to determine the search start position for the next reordering process from the address range specified by more received commands, rather than from the address where the magnetic head 14 is located at the start of the reordering process.
[0087] The range of addresses specified by more commands can be determined using a command address distribution and a filter. In one example, the command address parser 37 uses a linear filter as shown in Figure 14. The linear filter has a width over the address range and a maximum coefficient at the center of the address range. The linear filter has coefficients that decrease linearly from the center toward both sides. Values B and C in Figure 14 are values of arbitrary magnitude and described in arbitrary units.
[0088] Figure 15 shows an example of the result of applying the filter shown in Figure 14 to the command address distribution shown in Figure 13. The value D in Figure 15 can have any size. By applying the filter, the number of received commands in the command address distribution is converted into an evaluation value by multiplying it by a coefficient. Received commands in address ranges where many received commands exist in the surrounding addresses have a higher evaluation value. Address ranges with a high concentration of evaluation values are selected as the target for searching the starting position for the next reordering process. In the example in Figure 15, the address range enclosed by the dashed line is selected. Then, the address at the center of the address range or near the center is used as the starting position for the next reordering process. Hereafter, addresses at the center of the address range or near the center may be referred to as dense region addresses.
[0089] Figure 16 shows a flow of an operation of a magnetic disk device according to the second embodiment. Specifically, Figure 16 shows the flow of determining the search start position in the following reordering process. The flow in Figure 16 starts when the command address analysis unit 37 receives notification of the completion of the reordering process. In one example, the notification of the completion of the reordering process is sent from the command search unit 34 or the RW control unit 31.
[0090] As shown in Figure 16, the command address analysis unit 37 calculates the received command density (of candidate commands found within an address range) from the address range of candidate commands discovered during the current reordering process (step ST21).
[0091] If the density of received commands is greater than the threshold value (step ST22_Yes), the flow in Figure 16 terminates.
[0092] If the density of received commands is below a certain threshold (step ST22_No), the command address analysis unit 37 instructs the RW control unit 31 to use a specified location (step ST23). The instruction to use a specified location means that the dense region address should be used as the search starting position when the next reordering process begins. The flow in Figure 16 ends when step ST23 is completed.
[0093] Figure 17 shows a flow of a certain operation in a magnetic disk device according to the second embodiment. Specifically, Figure 17 shows a subflow of the selection of candidate commands in Figure 9 (step ST1).
[0094] As shown in Figure 17, the command search unit 34 determines whether it has received an instruction to use a specified location (step ST31). If it has not received an instruction (step ST31_No), the flow proceeds to step ST11. That is, the command search unit 34 searches for candidate commands using the address closest to the address where the magnetic head 14 is currently located as the search starting position. The flow from step ST11 onward is the same as in Figure 10.
[0095] If instructions have been received (step ST31_Yes), the command search unit 34 sets the key K closest to the address of the specified location that it has been instructed to use as key Ks_c (step ST32). That is, the command search unit 34 searches for candidate commands using the address of the specified location as the search start position. Step ST32 continues to step ST11.
[0096] The magnetic disk device 1 of the second embodiment calculates the density of received commands within a range of addresses of candidate commands discovered during a certain reordering process. If the command density is low, an address in a region with a high density of received commands is used as the starting position for the search in the next reordering process. This suppresses bias in the range where unprocessed commands are searched to a specific range, and candidate commands can be discovered efficiently.
[0097] When the second embodiment is applied to the first embodiment, candidate commands can be found more efficiently than when either the first or second embodiment is implemented alone, as described below. That is, the first embodiment allows for the efficient discovery of unprocessed commands specifying addresses around the address where the magnetic head 14 is currently located. However, depending on the address specified by the unprocessed command, it may be more efficient to process multiple unprocessed commands in address ranges other than those around the current address. Therefore, in the second embodiment, if the density of received commands in the address range of the candidate command is low, the search start position for the next reordering process is set to an address in a region with high command density, instead of the address of the magnetic head 14 at the start of the next reordering process. This prevents the search start position from being biased and consequently becoming inefficient.
[0098] While several embodiments of the present invention have been described, these embodiments are presented as examples only and are not intended to limit the scope of the invention. These embodiments can be carried out in a variety of other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their variations are included in the scope and spirit of the invention, as well as in the claims and their equivalents. [Explanation of Symbols]
[0099] 1… Magnetic disk drive, 2…Host device, 11… Magnetic disk, 12... Spindle motor, 13... Arm, 14… Magnetic head, 15…Voice coil motor, 16…Motor driver, 17... Head amplifier, 18...RW channel, 21…CPU, 22...ROM, 23...RAM, 24...buffer memory, 25…HDD controller, 31...RW control unit, 32... Database, 33...Database operation unit, 34... Command search unit, 35... Command selection section,
Claims
1. A magnetic disk containing multiple areas, each with its own unique address, Memory that stores multiple unprocessed commands, A controller stores a tree-like database in memory, the structure includes multiple nodes each associated with multiple addresses specified by multiple pending commands, two of the nodes are associated with each other, and selects a candidate command to be executed next from among the multiple pending commands, from a command associated with an address greater than the start address and closest to the start address, and a command associated with an address less than the start address and closest to the start address. A magnetic disk drive equipped with the following features.
2. The controller selects as a candidate command a command associated with one of the following addresses: a command associated with an address greater than the start address and closest to the start address, and a command associated with an address less than the start address and closest to the start address, which is closer to the start address. The magnetic disk device according to claim 1.
3. The controller selects the command with the lower execution cost among the next command to be executed and the candidate command as the next most recent command to be executed. The magnetic disk device according to claim 2.
4. Equipped with a magnetic head, The starting address is the address closest to the address of the magnetic head's position among the plurality of addresses. The magnetic disk device according to claim 3.
5. The aforementioned starting address is an address within an address range selected based on the density of received commands. The magnetic disk device according to claim 3.
6. In the first reordering process of the plurality of unprocessed commands, the selection of a candidate command and the comparison of the execution cost of the candidate command and the execution cost of the next command to be executed are repeated. After the first reordering process, a second reordering process is performed on the multiple unprocessed commands in the memory. If the number of received commands in the first address range falls below a first value, the second reordering process searches for candidate commands using addresses within the address range selected based on the density of received commands. The first address range includes the addresses of each of a plurality of candidate commands whose execution cost is compared with the execution cost of the next command to be executed in the first reordering process. The magnetic disk device according to claim 3.
7. A magnetic disk containing multiple areas, each with its own unique address, Memory that stores multiple unprocessed commands, A database of multiple unprocessed commands in the memory is stored in the memory. In each of the first and second reordering processes, the following steps are repeatedly performed: selecting a candidate command from among a plurality of unprocessed commands in memory that is a candidate for the next execution, and comparing the execution cost of the candidate command with the execution cost of the next command to be executed. If the number of received commands in the first address range falls below a first value, the second reordering process uses addresses within the address range selected based on the density of received commands to search for a candidate for the next command to be executed from among a plurality of unprocessed commands in the memory. Controller and Equipped with, The first address range includes the addresses of each of a plurality of candidate commands whose execution cost is compared with the execution cost of the next command to be executed in the first reordering process. Magnetic disk drive.
8. The aforementioned plurality of nodes include a parent node, a first leaf node, a second leaf node, The parent node includes a first key associated with a first address, a first pointer to a node containing an address smaller than the first address, and a second pointer to a node containing an address larger than the first address. The first leaf node includes a second key that is referenced by the first pointer and associated with a second address, and is associated with a first command that specifies the second address. The second leaf node includes a third key that is referenced by the second pointer and associated with a third address, and is associated with a second command that specifies the third address. A magnetic disk device according to any one of claims 1 to 6.
9. The database includes a B+ tree structure of the plurality of nodes, A magnetic disk device according to any one of claims 1 to 6.
Citation Information
Patent Citations
Magnetic disk device and magnetic head control method
JP2019053809A