Patent Publication Number: US-11024336-B1

Title: Magnetic disk device and memory management method of magnetic disk device

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
     This application is based upon and claims the benefit of priority from Japanese Patent Application No. 2020-035744, filed Mar. 3, 2020, the entire contents of which are incorporated herein by reference. 
     FIELD 
     Embodiments described herein relate generally to a magnetic disk device and a memory management method of the magnetic disk. 
     BACKGROUND 
     In the magnetic disk device, data is temporarily written to the cache in order to improve the efficiency of random writing. The data written to the cache is saved in a nonvolatile memory such as a serial flash memory. When power is lost, power is supplied by, for example, the back electromotive force of the spindle motor, and cache data is saved in a power loss protection (PLP) buffer, which is one of the nonvolatile memories. This protects the data when the power is lost. 
     For example, when the amount of the data can be written to the PLP buffer with the processing thread of the write command received from the host, the hard disk controller (hereinafter referred to as an HDC) uses a serial-attached SCSI (SAS) to send response frames, thereby notifying the host of the completion of the write command. When the completion notification of the write command is made, even when the power is lost after the notification, the write data to be notified needs to be able to be read normally after the power is restored. 
     Since the capacity of the PLP buffer is finite, when write commands are executed with a plurality of processing threads, like a hard disk with a split actuator configuration, a magnetic disk device that has a plurality of logical unit numbers (LUNs) is required to efficiently share the PLP buffer with the write command processing threads in each LUN in case of power loss. The LUN is an identifier allocated to a plurality of independent logical block addressing (LBA) spaces in the magnetic disk device. 
     The embodiment of the present invention is to provide a magnetic disk device that can efficiently share the memory (PLP buffer) with the write command processing threads in each LUN even when it is a magnetic disk device having a plurality of independent LBA spaces (LUN) in one device, and the memory management method thereof. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  is a schematic diagram showing an example of a schematic configuration of a magnetic disk device according to an embodiment. 
         FIG. 2  is a diagram showing an example of a schematic configuration of a system controller of the magnetic disk device according to the embodiment. 
         FIG. 3  is a flowchart showing an example of the buffer management process in the magnetic disk device according to a first embodiment. 
         FIG. 4  is a schematic diagram showing a specific example of whether the command completion notification condition (unwritten data amount determination condition and unwritten data total amount determination condition) in the buffer management process in the magnetic disk device according to the first embodiment holds. 
         FIG. 5  is a schematic diagram showing another specific example of whether the command completion notification condition (unwritten data amount determination condition and unwritten data total amount determination condition) in the buffer management process in the magnetic disk device according to the first embodiment holds. 
         FIG. 6  is a schematic diagram showing still another specific example of whether the command completion notification conditions (unwritten data amount determination condition and unwritten data total amount determination condition) in the buffer management process in the magnetic disk device according to the first embodiment holds. 
         FIG. 7  is a flowchart shewing an example of the buffer management process in the magnetic disk device according to a second embodiment. 
         FIG. 8  is a schematic diagram showing a specific example of whether the command completion notification condition (adjustment data total amount determination condition) in the buffer management process in the magnetic disk device according to the second embodiment holds. 
         FIG. 9  is a schematic diagram showing another specific example of whether the command completion notification condition (adjustment data total amount determination condition) in the buffer management process in the magnetic disk device according to the second embodiment holds. 
         FIG. 10  is a schematic diagram showing still another specific example of whether the command completion notification condition (adjustment data total amount determination condition) in the buffer management process in the magnetic disk device according to the second embodiment holds. 
         FIG. 11  is a flowchart showing an example of the buffer management process in the magnetic disk device according to a third embodiment. 
         FIG. 12  is a schematic diagram showing a specific example of whether the command completion notification condition (adjustment data amount determination condition and adjustment data total amount determination condition) in the buffer management process in the magnetic disk, device according to the third embodiment holds. 
         FIG. 13  is a schematic diagram showing another specific example of whether the command completion notification condition (adjustment data amount determination condition and adjustment, data total amount determination condition) in the buffer management process in the magnetic disk device according to the third embodiment holds. 
         FIG. 14  is a schematic diagram showing still another specific example of whether the command completion notification condition (adjustment data amount determination condition and adjustment data total amount determination condition) in the buffer management process in the magnetic disk device according to the third embodiment holds. 
         FIG. 15  is a schematic diagram showing a specific example of whether the command completion notification condition (unwritten data amount determination condition) in the buffer management process in the magnetic disk device according to the modification of the first embodiment holds. 
         FIG. 16  is a schematic diagram showing another specific example of whether the command completion notification condition (unwritten data amount determination condition) in the buffer management process in the magnetic disk device according to the modification of the first embodiment holds. 
         FIG. 17  is a schematic diagram showing a specific example of whether the command completion notification condition (adjustment data amount determination condition and adjustment data total amount determination condition) in the buffer management process in the magnetic disk device according to the modification of the third embodiment holds. 
     
    
    
     DETAILED DESCRIPTION 
     In general, according to one embodiment, a magnetic disk device includes a magnetic disk, an actuator that writes data to the magnetic disk, a nonvolatile memory that saves the data that is not written to the magnetic disk, a controller that, controls the actuator and the nonvolatile memory, where the controller executes a write command for instructing the writing of the data to the magnetic disk, where the write command is transmitted from a host, where the controller notifies the host of execution completion of the write command. The controller determines a first determination condition of whether a total value of an amount of the data for which execution completion has not been notified in one processing thread that executes the write command, where the data that has not been written to the magnetic disk, and an amount of the data for which execution completion has been notified in another processing thread that executes the write command, where the data has not been written to the magnetic disk, is less than or equal to a capacity of the nonvolatile memory holds. When the first determination condition holds, the controller notifies the host of execution completion of the write command in the one processing thread. 
     Hereinafter, the magnetic disk device according to the embodiments will be described with reference to  FIGS. 1 to 17 . 
     First Embodiment 
       FIG. 1  is a schematic diagram showing an example of a configuration of a magnetic disk device  1  according to the first embodiment.  FIG. 1  shows a dual-actuator type magnetic disk device  1  including a plurality of (two as an example) actuators. 
     The magnetic disk device  1  includes a head disk assembly (hereinafter referred to as an HDA)  2 , driver ICs  3   a  and  3   b , head amplifier integrated circuits (hereinafter referred to as a head amplifier IC)  4   a  and  4   b , a volatile memory (hereinafter referred to as a buffer)  5 , a nonvolatile memory  6 , a system controller (a first controller)  7   a , and a system controller (a second controller)  7   b . Further, the magnetic disk device  1  is communicatively connected to a host  3 . 
     The HDA  2  includes a magnetic disk (hereinafter simply referred to as a disk)  21 , a spindle motor (hereinafter referred to as an SPM)  22 , arms  23   a  and  23   b , and voice coil motors (hereinafter referred to as a VCM)  24   a  and  24   b.    
     The disk  21  is a magnetic recording medium having recording faces where, for example, one, of the faces, on which data is magnetically recorded. A recording area  21   a  that can be used by the user and a system area  21   b  in which information necessary for the system management is written are allocated to the recording area of the disk  21 . The disk  21  is driven and rotated by the SFM  22 . The SPM  22  is driven by electric power supplied from a power supply (hereinafter referred to as a main power supply)  9  of the magnetic disk device  1  via the driver IC  3   a . The number of disks  21  may be plural. Further, the disk  21  may be provided with recording faces on both sides, and arms (heads) may be disposed corresponding to the respective recording faces. 
     The arm  23   a  and the VCM  24   a  constitute an actuator (hereinafter referred to as a first actuator). A head  25   a  is mounted on the arm  23   a . The VCM  24   a  is driven by electric power supplied from the main power supply  9  via the driver IC  3   a , and controls the movement of the arm  23   a  to position the head  25   a  at a target position on the disk  21 . Similarly, the arm  23   b  and the VCM  24   b  constitute an actuator (hereinafter, referred to as a second actuator). A head  25   b  is mounted on the arm  23   b . The VCM  24   b  is driven by electric power supplied from the main power supply  9  via the driver IC  3   b , and controls the movement of the arm  23   b  to position the head  25   b  at a target position on the disk  21 . 
     The heads  25   a  and  25   b  include a slider as a main body and includes read heads RHa and RHb and write heads WHa and WHb, respectively, mounted on the slider. The read heads RHa and RHb read data recorded in the data tracks on the disk  21 . The write heads WHa and WHb write data to the disk  21 . The heads  25   a  and  25   b  write data to the disk  21  in block units including at least one sector, and read data from the disk  21  in block units. The sector is a minimum unit of data read from the disk  21  or data written to the disk  21 . 
     The driver IC  3   a  controls the drive of the SPM  22  and the VCM  24   a  according to the control from the system controller  7   a  (specifically, a CPU  71   a  described later). Further, the driver IC  3   b  controls the drive of the VCM  24   b  according to the control from the system controller  7   b  (specifically, a CPU  71   b  described later). 
     The driver IC  3   a  includes a backup power supply unit  31 . As described below, in the embodiment, the system controller  7   a  corresponds to a master (main) system-on-a-chip (SoC) of the magnetic disk device  1 , and the system controller  7   b  corresponds to a slave (sub) SoC. The backup power supply unit  31  may be provided in the master (main) ScC, but may be provided in the slave (sub) SoC in addition to the master SoC. 
     The backup power supply unit  31  generates electric power in place of the main power supply  9  when the main power supply  9  of the magnetic disk device  1  is lost (cut off). That is, the backup power supply unit  31  generates power for executing the data protection process of the magnetic disk device  1  when the main power supply  9  is lost. The data protection process includes a power loss protection (PLP) process that secures write data ever when the main power supply  9  is lost. The PLP process is a process of storing data that has not been written (recorded) to the disk  21  at the time of loss of the main power supply  9  in the nonvolatile memory  6  described later. The generated power is supplied to the system controllers  7   a  and  7   b , the buffer  5 , and the nonvolatile memory  6 . The backup power supply unit  31  uses the back electromotive force of the SPM  22  to generate this power. 
     The driver IC  3   a  includes a monitoring unit  32  that monitors the supply status of the voltage from the main power supply  9 . The voltage (supply voltage) supplied from the main power supply  9  is a voltage of supply power for driving the actuators (the arms  23   a  and  23   b  and the VCMs  24   a  and  24   b ) by the driver ICs  3   a  and  3   b.    
     The head amplifier ICs  4   a  and  4   b  include a read amplifier and a write driver. The read amplifier amplifies a read signal read from the disk  21  to output it to the system controllers  7   a  and  7   b  (specifically, HDCs  74   a  and  74   b  described later). The write driver outputs a write current according to the write data output from the HDCs  74   a  and  74   b  to the heads  25   a  and  25   b.    
     The buffer  5  is a semiconductor memory that temporarily records data and the like transmitted and received between the magnetic disk device  1  and the host  8 . The buffer  5  is, for example, a dynamic random access memory (DRAM), a static random access memory (SRAM), a synchronous dynamic random access memory (SDRAM), a ferroelectric random access memory (FeRAM), or a magneto resistive random access memory (MRAM). Part of the storage area of the buffer  5  is used as a volatile cache  5   a . The volatile cache  5   a  is a storage area in which the write data written to the disk  21  is temporarily stored. Another part of the storage area of the volatile memory  5  stores data necessary for processing in respective units of the magnetic disk device  1 . 
     The nonvolatile memory  6  is a semiconductor memory that records data stored even when power supply is cut off. The nonvolatile memory  6  is, for example, a NOR type or NAND type flash read only memory (FROM)). Part of the storage area of the nonvolatile memory  6  is used as a system area  6   a . An initial program loader (IPL) is stored in advance in part of the system area  6   a . The CPUs  71   a  and  71   b  described later loads at least part of the control program stored in the disk  21  into control memories  75   a  and  75   b  described later, for example, by performing the IPL when the main power supply  9  is turned on. 
     Another part of the storage area of the nonvolatile memory  6  is used as a nonvolatile cache  6   b . The nonvolatile cache  6   b  is a memory used for temporarily storing data that is written to the volatile cache  5   a , but that has not yet been written (recorded) to the disk  21  (hereinafter referred to as unwritten data) until it is written to the disk  21 . The data stored in the nonvolatile cache  6   b  is deleted when written to the disk  21 . In the PLP process executed when the main power supply  9  is lost, the nonvolatile cache  6   b  is used as a storage area in which unwritten data left in the volatile cache  5   a  at the time of power loss is saved from the volatile cache  5   a . Hereinafter, the nonvolatile cache  6   b  will be described as a PLP buffer  6   b.    
     The system controllers  7   a  and  7   b  are realized by using, for example, a large scale integrated circuit (LSI) called SoC in which a plurality of elements is integrated in a single chip. The system controller  7   a  is a controller that controls the first actuator (the arm  23   a  and the VCM  24   a ), the driver TC  3   a , the head amplifier IC  4   a , the buffer  5 , and the nonvolatile memory  6 . The system controller  7   b  is a controller that controls the second actuator (the arm  23   b  and the VCM  24   b ), the driver IC  3   b , and the head amplifier IC  4   b.    
       FIG. 2  is a diagram showing an example of a schematic configuration of the system controllers  7   a  and  7   b . The system controller  7   a  and the system controller  7   b  have the same configuration. The system controller  7   a  corresponds to the master (main) ScC of the dual-actuator type magnetic disk device  1 . The system controller  7   b  corresponds to the slave (sub) SoC of the dual-actuator type magnetic disk device  1 . 
     As shown in  FIG. 2 , these system controllers  7   a  and  7   b  includes the CPUs  71   a  and  71   b , buffer control units  72   a  and  72   b , data communication circuits  73   a  and  73   b , hard disk controllers (hereinafter referred to as an HOC)  74   a  and  74   b , and the control memories  75   a  and  75   b , respectively. 
     The system controller  7   a  is connected to the driver IC  3   a , the head amplifier IC  4   a , the buffer  5 , the nonvolatile memory  6 , the system controller  7   b , and the host  6 . On the other hand, the system controller  7   b  is connected to the driver IC  3   b , the head amplifier IC  4   b , and the system controller  7   a . The system controller  7   a  and the system controller  7   b  are connected by a communication path C. The communication path C is a communication path capable of high-speed data transfer. 
     The CPU  71   a  and the CPU  71   b  are main controllers that control respective units of the magnetic disk device  1 . The CPUs  71   a  and  71   b  control the rotation speed of the SPM  22  via the driver ICs  3   a  and  3   b , control the VCK  24   a  and  24   b , and perform servo control of positioning the heads  25   a  and  25   b . At the time of reading data (at the time of executing a read command), the CPUs  71   a  and  71   b  control the operation of reading data from the disk  21  and the process of the read data. At the time of writing data (at the time of executing a write command), the CPUs  71   a  and  71   b  control the operation of writing data to the disk  21 , and select the save destination of the write data transferred from the host  6 . The CPUs  71   a  and  71   b  are connected to the driver ICs  3   a  and  3   b , the HDCs  74   a  and  74   b , and the control memories  75   a  and  75   b , respectively. 
     When the main power supply  9  is turned on, the CPUs  71   a  and  71   b  execute the IPL from the system area  6   a  of the nonvolatile memory  6 , and loads the control program stored in the disk  21  into the control memories  75   a  and  75   b . As a result, the CPUs  71   a  and  71   b  execute the process for operating the system controllers  7   a  and  7   b  m a predetermined operation mode. As an example, the CPU  71   a  causes the system controller  7   a  to function as a master (main) SoC, and the CPU  71   b  causes the system controller  7   b  to function as a slave (sub) SoC. 
     The buffer control units  72   a  and  72   b  control data transfer between the buffer  5  and the system controllers  7   a  and  7   b . In the embodiment, as an example, the system controller  7   b  functions as a slave (sub) SoC, so that the function of the buffer control unit  72   b  is disabled. 
     The data communication circuits  73   a  and  73   b  mutually connect the system controller  7   a  and the system controller  7   b  via the communication path C, and control transmission/reception of data between them. 
     The HDCs  74   a  and  74   b  execute signal processing of read data and write data according to instructions from the CPUs  71   a  and  71   b . The HDCs  74   a  and  74   b  have a circuit or a function for measuring the signal quality of read data. For example, the HDCs  74   a  and  74   b  have a function of performing an error checking and correcting (ECC) process on read data read from the disk  21 . The HDCs  74   a  and  74   b  are connected to the head amplifier ICs  4   a  and  4   b  and the CPUs  71   a  and  71   b . In this embodiment, since the system controller  7   a  functions as a master (main) SoC, the HDC  74   a  receives the read command and the write command from the host  8  according to the instruction from the CPU  71   a , and controls data transfer to and from the host  8 . The HDC  74   a  is connected to the nonvolatile memory  6 . 
     The control memories  75   a  and  75   b  are volatile memories such as the DRAM. Part of the control program is loaded in the storage areas of the control memories  75   a  and  75   b . In addition, management tables  78   a  and  73   b  are stored in the storage areas of the control memories  75   a  and  75   b . The management tables  76   a  and  76   b  include volatile cache directory information and PLP buffer directory information. The volatile cache directory information is information for managing the location of data in the volatile cache  5   a  in units of blocks of a fixed size. The PLP buffer directory information is information for managing the location of data in the PLP buffer  6   b  in units of blocks of a fixed size. Further, part of the storage areas of the control memories  75   a  and  75   b  are used as command buffers  77   a  and  77   b . The command buffers  77   a  and  77   b  store a queue of read commands and write commands received from the host  3 . The read command and the write command are executed in the order of the queue with the processing thread corresponding to each command, for example. 
     The system controllers  7   a  and  7   b  operate as follows when reading and writing data from and to the disk  21 . At this time, communication with the host  3  is controlled by the system controller  7   a , which is a master (main). As described below, the first data is data that is written to or read from the disk  21  by using the head  25   a  and the second data is data that is written to or read from the disk  21  by using the head  25   b.    
     When receiving, from the host  8 , a read command instructing the reading of the read data from the disk  21 , the system controller  7   a  divides the read data into the first data and the second data based on the instruction of CPU  71   a , and notifies the CPU  71   b  of the information related to the second data via the communication path C. The CPU  71   a  stores the first data in the buffer  5  via the head amplifier IC  4   a , the HOC  74   a , and the buffer control unit  72   a . The CPU  71   b  stores the second data in the buffer  5  via the head amplifier IC  4   b , the HOC  74   b , the data communication circuit  73   b , the communication path C, the data communication circuit  73   a , and the buffer control unit  72   a . Then, the CPU  71   a  performs control  30  as to transmit, to the host  8 , the first data and the second data stored in the buffer  5 . 
     Further, when receiving, from the host  8 , a write command instructing the writing of write data to the disk  21 , the system controller  7   a  stores the write data in the buffer  5  (the volatile cache  5   a ) via the buffer control unit  72   a . The CPU  71   a  divides the write data into the first data and the second data, and notifies the CPU  71   b  of the information regarding the second data via the communication path C. The CPU  71   a  writes (records) the first data from the volatile cache  5   a  to the disk  21  via the buffer control unit  72   a , the HDC  74   a , and the head amplifier IC  4   a . In contrast, the CPU  71   b  writes the second data (recorded) from the volatile cache  5   a  to the disk  21  via the buffer control unit  72   a , the data communication circuit  73   a , the communication path C, the data communication circuit  73   b , the HDC  74   b , and the head amplifier IC  4   b.    
     The condition for separating the read data or the write data into the first data and the second data may be, for example, based on separation which is performed in track units, head units, or disk units when writing or reading data, or separation into the data processed in main and the data processed in background. 
     Next, a method of managing the PLP buffer  6   b  for data protection process including the PLP process in the magnetic disk device  1  according to the embodiment will be described. 
     In this embodiment, the two logical unit numbers (LUNs) are allocated to the magnetic disk device  1 . The LUN is an identifier allocated in the magnetic disk device  1  so as to correspond to a plurality of independent logical block addressing (LBA) spaces. The first actuator, in short, the system controller  7   a  executes the writing of write data with a write command processing thread in one LUN (hereinafter, referred to as a LUNA). In contrast, the second actuator, in snort, the system controller  7   b  executes the writing of write data with a write command processing thread in the other LUN (referred to as an LUNB). That is, the LUNA corresponds to an identifier associated with the system controller  7   a , and the LUNB corresponds to an identifier associated with the system controller  7   b . At a point in time when the write command is being executed, the processing thread in which the write command is being executed and the LUN uniquely correspond. 
       FIG. 3  is a flowchart showing a management method of the PLP buffer  6   b  in the data protection process. Specifically, a series of processing (hereinafter referred to as the buffer management process) executed when reserving a storage area of the write data in the PLP buffer  6   b  in the two LUNA and LUNB is shewn. 
     As shown in  FIG. 3 , in the buffer management process, the system controller  7   a  detects whether a write command is received from the host  8  (S 101 ). At this time, the CPU  71   a  determines whether the HOC  743  has received the write command from the host  8 . 
     When the write command has not been received, the system controller  7   a  ends the buffer management process. 
     In contrast, when the write command is received, the CPU  71   a  stores the write data in the buffer  5  (the volatile cache  5   a ) with the processing thread of the write command (S 102 ). 
     Next, the CPU  71   a  acquires data (determination parameter) necessary for determining the command completion notification condition (S 103 ). The command completion notification condition is a determination condition of whether the host  8  can be notified that the write command has been normally executed. Hereinafter, this notification is referred to as a command completion notification. The determination parameters are various values indicating the correlation with the PLP buffer  6   b  and the LUN. Here, the two determination parameters are the unwritten data amount in the write command processing thread and the total value of the unwritten data amount (hereinafter referred to as the unwritten data total amount). 
     The unwritten data amount is the LUN that is currently executing the write command (hereinafter referred to as the target LUN). In the case of the LUNA, as an example, this is the amount of write data for which the storage area of the PLP buffer  6   b  is attempted to be reserved. In other words, in the write command processing thread that is attempting to make notification of the completion (currently command completion notification has not been made), this is the amount of write data for which it is not yet determined that the writing (saving) to the PLP buffer  6   b  is possible. In addition, the LUN for which the write command is already executed is hereinafter referred to as the non-target LUN. In the case of the LUNB, as an example, this is the amount of write data for which the storage area of the PLP buffer  6   b  is already reserved. In other words, in the write command processing thread that has already made notification of the completion of the write command (currently command completion notification has been made), this is the amount of write data that has not been written (recorded) to disk  21 , and for which it is determined that the writing (saving) to the PLP buffer  6   b  is possible. 
     The non-target LUN is the LUNB as an example, but includes the LUNA in the following case. For example, this is the case where the command completion notification has already been made, but write data has not been written (recorded) to the disk  21  yet with the LUNA processing thread that has executed a write command different from the write command currently being executed in LUNA, so that there is the write data for which the storage area of the PLP buffer  6   b  is reserved. In this case, the unwritten data amount of the processing thread in the remaining LUNA of the PLP buffer  6   b  is also added to the unwritten data total amount. 
     The unwritten data total amount is the total amount of the unwritten data amount in the target LUN and the unwritten data amount in the non-target LUN. That is, the unwritten data total amount is the total amount of, in all LUNs (LUNA and LUNB in this embodiment), the amount of write data which has not been written (recorded) to disk  21  although the command completion notification has already been made, and for which the storage area of the PLP buffer  6   b  is reserved, and the unwritten data amount of the target LUN. 
     In other words, the PLP buffer  6   b  is in a state where a storage area in which the write data of the unwritten data total amount can be written is reserved. Therefore, the PLP buffer  6   b  has a storage area in which the write data can be written (saved) by a capacity obtained by subtracting the unwritten data total amount from the buffer capacity. The buffer capacity is a storage capacity capable of writing the write data to the PLP buffer  6   b  to the maximum. For example, it is set as the maximum value of the storage capacity that can be written (saved) within the time during which the operation is allowed by the back electromotive force of the SPM  22 . 
     The unwritten data amount and the unwritten data total amount are calculated, for example, by the block address given to the storage area of the PLP buffer  6   b , in other words, the number of blocks. The block address information (SVSC) of the PLP buffer  6   b  corresponding to the write data written (recorded) to the disk  21  is given from the driver ICs  3   a  and  3   b  to the CPUs  71   a  and  71   b . The unwritten data amount with the write command processing thread in each LUN is calculated as the number of blocks corresponding to the difference between the final block address of the write command and the block address corresponding to the write data written to the disk  21 . 
     When the write data is written to the disk  21  with the write command processing thread, the storage area that can be reserved in the PLP buffer  6   b  is released by the amount, of the write data. Therefore, when the unwritten data amount is negative, it means that the write data was written to the disk  21  in the number of blocks corresponding to the write data amount or more with the write command processing thread. That is, in this case, the writing of the write data to the disk  21  is completed, and the value of the unwritten data amount by the corresponding write command is set to 0 (zero). 
     When acquiring the determination parameter, the CPU  71   a  determines the command completion notification condition based on the determination parameter. Here, the unwritten data total amount determination condition (first determination condition) and the unwritten data amount determination condition (second determination condition) are determined as the command completion notification conditions. As an example, the unwritten data amount determination condition is first determined (S 104 ), and then the unwritten data total amount determination condition is determined (S 105 ). The determination order of these determination conditions may be reversed. 
     The unwritten data amount determination condition is a determination condition of whether the unwritten data amount of the target LUN is less than or equal to the maximum occupiable capacity. The maximum occupiable capacity is the maximum value of the storage area, of the PLP buffer  6   b , that can be occupied by one LUN. In determining the unwritten data amount determination condition, the CPU  71   a  compares the unwritten data amount of the target LUN with the maximum occupiable capacity. When the unwritten data amount of the target LUN is less than or equal to the maximum occupiable capacity, the CPU  71   a  determines that the unwritten data amount determination condition holds. On the other hand, when the unwritten data amount of the target LUN exceeds the maximum occupiable capacity, the CPU  71   a  determines that the unwritten data amount determination condition does not hold. However, whether the unwritten data amount determination condition when the unwritten data amount matches the maximum occupiable capacity holds may be opposite to the above. 
     When the unwritten data amount determination condition holds, the CPU  71   a  determines the unwritten data total amount determination condition (S 105 ). The unwritten data total amount determination condition is a determination condition of whether the unwritten data total amount is less than or equal to the buffer capacity. In determining the unwritten data total amount determination condition, the CPU  71   a  compares the unwritten data total amount with the buffer capacity. When the unwritten data total amount is less than or equal to the buffer capacity, the CPU  71   a  determines that the unwritten data total amount determination condition holds. On the ocher hand, when the unwritten data total amount exceeds the buffer capacity, the CPU  71   a  determines that the unwritten data total amount determination condition does not hold. However, whether the unwritten data total amount determination condition when the unwritten data total amount matches the buffer capacity holds may be opposite to the above. 
     When the unwritten data total amount determination condition holds, the CPU  71   a  determines that the write command for the target LUN is complete, and sends a command completion notification to the host  8  via the HOC  74   a  (S 106 ). In this case, a storage area in which write data can be written with the write command processing thread in the target LUN is left in the PLP buffer  6   b , and the write data can be written to the PLP buffer  6   b . Therefore, it is possible to notify the host  8  of the command completion notification, that is, that the write command has been completed normally. 
     In contrast, when the unwritten data amount determination condition does not hold in S 104 , or when the unwritten data total amount determination condition does not hold in S 105 , the CPU  71   a  performs an unsatisfied process (S 107 ). In this case, the storage area in which the write data can be written with the write command processing thread in the target LUN is not left in the PLP buffer  6   b . Therefore, the write command for the target LUN is not completed, and the CPU  71   a  does not send the command completion notification to the host  8 . Instead, as the unsatisfied process, for example, a timeout process that ends the buffer management process after a predetermined time has elapsed, a retry process for ending the buffer management process when the command completion notification condition (unwritten data amount determination condition and unwritten data total amount determination condition) does not hold even after repeating the determination by a predetermined number of times, a process combining these processes, and the like are performed. It is possible to omit the unsatisfied process and the buffer management process may be ended when the command completion notification condition does not hold. 
       FIGS. 4 to 6  show specific examples of whether the command completion notification is made in the buffer management process shown in  FIG. 3 , that is, whether the command completion notification conditions (the unwritten data amount determination condition and the unwritten data total amount determination condition) hold. In the examples shown in  FIGS. 4 to 6 , PLP buffer  6   b  has a buffer capacity (MAX_CAP) of 100, and a maximum occupiable capacity (TH 1 ) of 80. The target LUN is the LUNA, and the non-target LUN is the LUNB. That is, the LUNA is currently attempting to issue a command completion notification by reserving a storage area of the write data in the PLP buffer  6   b  with a write command processing thread. On the other hand, in the LUNB, a storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread different from that of the LUNA, and the command completion notification is made. 
     In the example shown in  FIG. 4 , a storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread in the LUNB, and the unwritten data amount (DAB) is 10. The DAB is the unwritten data amount of the LUNB, which is a non-target LUN, and the amount of write data that has not been written (recorded) to disk  21 , and for which the storage area of the PLP buffer  6   b  remains to be reserved without released although the command completion notification has already been made. On the other hand, the unwritten data amount (DAA) of the LUNA, which is the target LUN, is 90. The DAA is the unwritten data amount of the LUNA, which is the target LUN, and the amount of write data for which the command completion notification has not been given yet, and for which the storage area of the PLP buffer  6   b  is attempted to be reserved. 
     The maximum occupiable capacity (TH 1 ) is 80. Since the unwritten data amount (DAA) of the LUNA exceeds the value, that is, DAA&gt;TH 1 , the unwritten data amount determination condition does not hold. In other words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. As a result, the LUNA command completion notification cannot be sent to the host  8 . 
     In this case, the unwritten data total amount is 100, which is the unwritten data amount (10+90) obtained by adding the DAA to the DAB. Therefore, since the unwritten data total amount is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, the unwritten data total amount determination condition holds. However, since the unwritten data amount determination condition does not hold as described above, the command completion notification condition does not hold, and the LUNA command completion notification cannot be sent to the host  8 . 
     In the example shown in  FIG. 5 , the unwritten data amount (DAB) of the LUB is 30. On the other hand, the unwritten data amount (DAA) of the LUNA is 80. Therefore, since the unwritten data amount (DAA) of the LUNA is less than or equal to the maximum occupiable capacity (TH 1 ), that is, DAA≤TH 1 , the unwritten data amount determination condition holds. 
     On the other hand, the unwritten data total amount (DAA+DAB) is 110. Therefore, since the unwritten data total amount (DAA+DAB) exceeds the buffer capacity (MAX_CAP), that is, DAA+DAB&gt;MAX_CAP, the unwritten data total amount determination condition does not held. In this case, the PLP buffer  6   b  does not have any storage area in which the write data of the unwritten data amount (DAA) of the LUNA can be written (saved). In other words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. 
     In this way, in the example shown in  FIG. 5 , the unwritten data amount determination condition holds, but the unwritten data total amount determination condition does not hold, so that the command completion notification condition does not hold and the LUNA command completion notification cannot be sent to the host  6 . 
     In the example shown in  FIG. 6 , the unwritten data amount (DAB) of the LUB is 20. On the other hand, the unwritten data amount (DAA) of the LUNA is 70. Therefore, the unwritten data amount (DAA) of the LUNA is less than or equal to the maximum occupiable capacity (TH 1 ), that is, DAA≤TH 1 , and the unwritten data amount determination condition holds. 
     On the other hand, the unwritten data total amount (DAA+DAB) is 90. Therefore, since the unwritten data total amount (DAA+DAB) is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, the unwritten data total amount determination condition holds. In this case, the PLP buffer  6   b  has a storage area in which the write data of the unwritten data amount (DAA) of the LUNA can be written (saved). In other words, the storage area of the write data can be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. 
     In this way, in the example shown in  FIG. 6 , since both the unwritten data amount determination condition and the unwritten data total amount determination condition hold, the command completion notification condition holds, and the LUNA command completion notification can be sent to the host  8 . 
     In the first embodiment described above, although the unwritten data amount determination condition and the unwritten data total amount determination condition are used as the write command completion notification condition, the command completion notification condition is not limited to this. For example, the adjustment data total amount, determination condition described below may be used as the command completion notification condition. An embodiment in which the adjustment data total amount determination condition is used as the command completion notification condition in this way will be described below as a second embodiment. The configuration of the magnetic disk device of the second embodiment is equivalent to the configuration of the magnetic disk device  1  of the first embodiment shown in  FIGS. 1 and 2 . 
     Second Embodiment 
       FIG. 7  is a flowchart showing an example of the buffer management process in this embodiment. Whether the command completion notification condition (adjustment data total amount determination condition) in the buffer management process holds will be described below with reference to the flowchart shown in  FIG. 7 . The control flow of the buffer management process of the present embodiment replaces part of the control flow of the first embodiment ( FIG. 3 ) with control unique to the second embodiment. Therefore, with respect to the control equivalent to that of the above-described first embodiment, the same step numbers are given and the description thereof is omitted, and only the control unique to the second embodiment will be described. 
     As shown in  FIG. 7 , in the buffer management process, when the write command is received (S 101 ) and the write data is stored in the buffer  5  (volatile cache  5   a ) with the write command processing thread (S 102 ), a CPU  71   a  acquires the determination parameter (S 103 ). The determination parameters are the unwritten data amount and the unwritten data total amount. 
     In the present embodiment, the unwritten data amount is adjusted (corrected) as necessary. Therefore, the CPU  71   a  determines the data amount adjustment necessity condition (S 201 ). The data amount adjustment necessity condition is a determination condition of whether the unwritten data amount needs to be adjusted. In determining the data amount adjustment necessity condition, the CPU  71   a  compares the unwritten data amount of each LUN with the occupation reserved capacity. The occupation reserved capacity is a capacity value of the storage area, of a PLP buffer  6   b , that one LUN is allowed to occupy without fail. That is, in the PLP buffer  6   b , the storage area of the occupation reserved capacity is reserved in advance as the storage area that each of the LUNs is allowed to occupy according to the number of the LUNs. The occupation reserved capacity may be a constant value for all LUNs, but may be a unique value set for each LUN or a variable value. When the unwritten data amount is less than the occupation reserved capacity, the CPU  71   a  determines that the data amount adjustment necessity condition holds. On the other hand, when the unwritten data amount is equal to or larger than the occupation reserved capacity, the CPU  71   a  determines that the data amount adjustment necessity condition does not held. 
     The occupation reserved capacity (TH 2 ) has a relationship with the maximum occupiable capacity (TH 1 ) and the buffer capacity (MAX_CAP) as shown by the following two relational expressions. The first relational expression is represented by TH 2 ≤TH 1 . The second relational expression is represented by TH 1 +(n−1)*TH 2 ≤MAX_CAP. In the second relational expression, n is the total number of the LUNs. As described above, the buffer capacity is a fixed value set as the maximum value of the storage capacity that can be written (saved) within the time during which the operation is allowed by the back electromotive force of an SPM  22 , for example. The occupation reserved capacity and the maximum occupiable capacity are set based on the buffer capacity set according to the back electromotive force so that both the first relational expression and the second relational expression hold. In other words, the occupation reserved capacity and the maximum occupiable capacity can be set to optimal values based on the buffer capacity under the condition that both the first relational expression and the second relational expression hold. 
     When the data amount adjustment necessity condition holds, the CPU  71   a  adjusts (corrects) the value of the unwritten data amount of the LUN to the value of the occupation reserved capacity (S 202 ). In this case, since the unwritten data amount is currently less than the occupation reserved capacity, it is necessary to reserve the storage area of the PLP buffer  6   b  up to the occupation reserved capacity in preparation for the future writing (saving) of the write data with the processing thread of the LUN. Therefore, the value of the unwritten data amount, of the LUN, which is currently less than the occupation reserved capacity is adjusted to the value of the occupation reserved capacity. When the unwritten data amount is adjusted, the unwritten data total amount is calculated using the value of the unwritten data capacity after adjustment. 
     On the other hand, when the data amount adjustment necessity condition does not hold in S 202 , the CPU  71   a  does not adjust (correct) the value of the unwritten data amount of the LUN. That is, since the unwritten data amount is currently equal to or larger than the occupation reserved capacity, it is not necessary to further reserve the storage area of the PLP buffer  6   b  for the write command processing thread in the LUN. Therefore, the unwritten data amount of the LUN which is currently less than the occupation reserved capacity is maintained as it is without being adjusted. 
     Subsequently, the CPU  71   a  determines the command completion notification condition based on the determination parameter. Here, the adjustment data total amount determination condition is determined as the command completion notification condition (S 203 ). 
     The adjustment data total amount determination condition is a determination condition of whether the unwritten data total amount is less than or equal to the buffer capacity. However, when the unwritten data amount is adjusted, the value of the unwritten data amount of the LUN is set as the value after adjustment (after correction), and the unwritten data total amount is calculated. In determining the adjustment data total amount determination condition, the CPU  71   a  compares the unwritten data total amount with the buffer capacity. When the unwritten data total amount is less than or equal to the buffer capacity, the CPU  71   a  determines that the adjustment data total amount determination condition holds. On the other hand, when the unwritten data total amount exceeds the buffer capacity, the CPU  71   a  determines that the adjustment data total amount determination condition does net hold. However, whether the adjustment data total amount determination condition when the unwritten data total amount matches the buffer capacity holds may be opposite to the above. 
     When the adjustment data total amount determination condition holds, the CPU  71   a  determines that the write command for the target LUN is complete, and sends a command completion notification to a host  8  via an HDC  74   a  (S 106 ). 
     On the other hand, when the adjustment data total amount determination condition does not hold in S 203 , the CPU  71   a  performs an unsatisfied process (S 107 ). In this case, the write command for the target LUN is not completed, and the CPU  71   a  does not send the command completion notification to the host  8 . 
       FIGS. 8 to 10  show specific examples of whether the command completion notification is made in the buffer management process shown in  FIG. 7 , that is, whether the command completion notification condition (adjustment data total amount determination condition) holds. In the example shown in  FIGS. 8 to 10 , the PLP buffer  6   b  has a buffer capacity (MAX_CAP) of 100, and an occupation reserved capacity (TH 2 ) of 10. The target LUN is the LUNA, and the non-target LUN is the LUNB. That is, the LUNA is currently attempting to issue a command completion notification by reserving a storage area of the write data in the PLP buffer  6   b  with a write command processing thread. On the other hand, in the LUNB, a storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread different from that of the LUNA, and the command completion notification is made. 
     In the example shown in  FIG. 8 , a storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread in the LUNB, and the unwritten data amount (DAB) is 50. On the other hand, the unwritten data amount (DAA) of the LUNA, which is the target LUN, is 60. In this case, since the value of the unwritten data amount (DAA) of the LUNA and the value of the unwritten data amount (DAB) of the LUNB both exceed the occupation reserved capacity (TH 2 ), they are maintained as they are without being adjusted (corrected). 
     The unwritten data total amount is 110, which is the actual unwritten data amount (50+60) obtained by adding the DAA to the DAB. Since the unwritten data total amount exceeds the buffer capacity (MAX_CAP), that is, DAA+DAB&gt;MAX_CAP, the adjustment data total amount determination condition does not hold. In other words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. Therefore, the LUNA command completion notification cannot be sent to the host  8 . 
     In the example shown in  FIG. 9 , the unwritten data amount (DAB) of the LUB is 5. In this case, since the value is less than the occupation reserved capacity (TH 2 ), the value of the unwritten data amount (DAB) of the LUNB is adjusted (corrected) to the value of TH 2  to be 10. On the other hand, the unwritten data amount (DAA) of the LUNA is 95. In this case, the value of the unwritten data amount (DAA) of the LUNA exceeds the occupation reserved capacity (TH 2 ), and therefore is maintained as it is without adjustment. 
     The unwritten data total amount is 105, which is the unwritten data total amount (10+95) obtained by adding the actual DAA to the adjusted DAB. Since the unwritten data total amount exceeds the buffer capacity (MAX_CAP), that is, DAA+DAB&gt;MAX_CAP, the adjustment data total amount determination condition does net hold. In ether words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. Therefore, the LUNA command completion notification cannot be sent to the host  8 . 
     The actual (that is, before adjustment) unwritten data amount (DAB) of the LUNB is 5, so that when the actual value is used, the unwritten data total amount is 100 (5+95) and is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, whereby the adjustment data total amount determination condition holds. However, it is necessary to reserve the storage area of the PLP buffer  6   b  up to the occupation reserved capacity (TH 2 ) in case the storage area of the write data with the LUNB processing thread is reserved in the future as described above. Therefore, the value of the unwritten data amount (DAB) of the LUNB is adjusted to the value of the occupation reserved capacity (TH 2 ), and the adjustment data total amount determination condition does not hold. 
     In the example shown in  FIG. 10 , the unwritten data amount (DAB) of the LUB is 40. On the ether hand, the unwritten data amount (DAA) of the LUNA is 60. In this case, since the value of the unwritten data amount (DAA) of the LUNA and the value of the unwritten data amount (DAB) of the LUNB both exceed the occupation reserved capacity (TH 2 ), they are maintained as they are without being adjusted (corrected). 
     The unwritten data total amount is 100, which is the actual unwritten data total amount (40+60) obtained by adding the DAA to the DAB. Since the unwritten data total amount is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, the adjustment data total amount determination condition holds. That is, the storage area of the write data can be reserved in the PLP buffer  6   b  with a write command processing thread in the LUNA, which is the target LUN, and the LUNA command completion notification can be sent to the host  8 . 
     Further, in addition to the adjustment data total amount determination condition in the second embodiment, an adjustment data amount determination condition described later may be used as the command completion notification condition. An embodiment in which the command completion notification condition is the adjustment data amount determination condition and the adjustment data total amount determination condition in this manner will be described below as a third embodiment. The configuration of the magnetic disk device of the third embodiment is equivalent to the configuration of the magnetic disk device  1  of the first embodiment shown in  FIGS. 1 and 2 . 
     Third Embodiment 
       FIG. 11  is a flowchart showing an example of the buffer management process in this embodiment. Whether the command completion notification conditions (adjustment data amount determination condition and adjustment data total amount determination condition) in the buffer management process holds will be described below with reference to the flowchart shown in  FIG. 11 . The control flew of the buffer management process of the present embodiment replaces part of the control flow of the second embodiment ( FIG. 7 ) with control unique to the third embodiment. Therefore, with respect to the control equivalent to that of the above-described second embodiment, the same step numbers are given and the description thereof is omitted, and only the control unique to the third embodiment will be described. 
     As shown in  FIG. 11 , in the buffer management process, when the write command is received (S 101 ) and the write data is stored in the buffer  5  (volatile cache  5   a ) with the write command processing thread (S 102 ), a CPU  71   a  acquires the determination parameter (S 103 ). The determination parameters are the unwritten data amount and the unwritten data total amount. 
     Since the unwritten data amount is adjusted (corrected) as necessary, the CPU  71   a  determines the data amount adjustment necessity condition (S 201 ). 
     When the data amount adjustment necessity condition holds, the CPU  71   a  adjusts (corrects) the value of the unwritten data amount of the LUN to the value of the occupation reserved capacity (S 202 ). When the unwritten data amount is adjusted, the unwritten data total amount is calculated using the unwritten data capacity after adjustment. On the other hand, when the data amount adjustment necessity condition does not hold, the CPU  71   a  does not adjust (correct) the value of the unwritten data amount of the LUN. Therefore, the unwritten data amount of the LUN which is currently less than the occupation reserved capacity is maintained as it is without being adjusted. 
     Subsequently, the CPU  71   a  determines the command completion notification condition based on the determination parameter. Here, the adjustment data amount determination condition and the adjustment data total amount determination condition are determined as the command completion notification conditions. As an example, first, the adjustment data amount determination condition is determined (S 301 ), and then the adjustment data total amount determination condition is determined (S 203 ). 
     The adjustment data amount determination condition is a determination condition of whether the unwritten data amount of the target LUN is less than or equal to the maximum occupiable capacity. However, when the unwritten data amount is adjusted, the value of the unwritten data amount is a value after adjustment (correction). In determining the adjustment data amount determination condition, the CPU  71   a  compares the unwritten data amount of the target LUN with the maximum occupiable capacity. When the unwritten data amount of the target LUN is less than or equal to the maximum occupiable capacity, the CPU  71   a  determines that the adjustment data amount determination condition holds. On the other hand, when the unwritten data amount of the target LUN exceeds the maximum occupiable capacity, the CPU  71   a  determines that the adjustment data amount determination condition does not hold. However, whether the adjustment data amount determination condition when the unwritten data amount matches the maximum occupiable capacity holds may be opposite to the above. 
     When the adjustment data amount determination condition holds, the CPU  71   a  determines the adjustment data total amount determination condition (S 203 ). When the adjustment data total amount determination condition holds, the CPU  71   a  determines that the write command for the target LUN is complete, and sends a command completion notification to a host  8  via an HOC  74   a  (S 106 ). 
     In contrast, when the adjustment data amount determination condition does not hold in S 301 , or when the adjustment data total amount determination condition does not hold in S 203 , the CPU  71   a  performs an unsatisfied process (S 107 ). In this case, the write command for the target LUN is net completed, and the CPU  71   a  does not send the command completion notification to the host  8 . 
       FIGS. 12 to 14  show specific examples of whether command completion notification is made in the buffer management process shown in  FIG. 11 , that is, whether the command completion notification conditions (adjustment data amount determination condition and adjustment data total amount determination condition) hold. In the examples shown in  FIGS. 12 to 14 , a PLP buffer  6   b  has a buffer capacity (MAX_CAP) of 100, a maximum occupiable capacity (TH 1 ) of 60, and an occupation reserved capacity (TH 2 ) of 10. The target LUN is the LUNA, and the non-target LUN is the LUNB. That is, the LUNA is currently attempting to issue a command completion notification by reserving a storage area of the write data in the PLP buffer  6   b  with a write command processing thread. On the other hand, in the LUNB, a storage area of the write data is already-reserved in the PLP buffer  6   b  with a write command processing thread, and the command completion notification is made. 
     In the example shown in  FIG. 12 , the write data is already written to the PLP buffer  6   b  with a write command processing thread in the LUNB, and the unwritten data amount (DAB) is 5. In this case, since the value is less than the occupation reserved capacity (TH 2 ), the value of the unwritten data amount (DAB) of the LUNB is adjusted (corrected) to the value of TH 2  to be 10. On the other hand, the unwritten data amount (DAA) of the LUNA is 70. In this case, the value of the unwritten data amount (DAA) of the LUNA exceeds the occupation reserved capacity (TH 2 ), and therefore is maintained as it is without adjustment. 
     Since the maximum occupiable capacity (TH 1 ) is 60 and the unwritten data amount (DAA) of the LUNA exceeds the value, that is, DAA&gt;TH 1 , the adjustment data amount determination condition does not hold. In other words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. Therefore, the LUNA command completion notification cannot be sent to the host  8 . 
     In this case, the unwritten data total amount is 80, which is the data amount (10+70) obtained by adding the actual DAA to the adjusted DAB. Therefore, since the unwritten data total amount is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, the adjustment data total amount determination condition holds. However, since the adjustment data amount determination condition does not hold as described above, the command completion notification condition does not hold and the LUNA command completion notification cannot be transmitted to the host  8 . 
     In the example shown in  FIG. 13 , the unwritten data amount (DAB) of the LUNB is 50. On the other hand, the unwritten data amount (DAA) of the LUNA is 60. In this case, since the value of the unwritten data amount (DAA) of the LUNA and the value of the unwritten data amount (DAB) of the LUNB both exceed the occupation reserved capacity (TH 2 ), they are maintained as they are without being adjusted (corrected). 
     The unwritten data total amount is 110, which is the unwritten data total amount (50+60) after adjustment obtained by adding the DAA to the DAB. Since she unwritten data total amount exceeds the buffer capacity (MAX_CAP), that is, DAA+DAB&gt;MAX_CAP, the adjustment data total amount determination condition does not hold. In other words, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNA, which is the target LUN. Therefore, the LUNA command completion notification cannot be sent to the host  8 . 
     In the example shown in  FIG. 14 , the unwritten data amount (DAB) of the LUB is 40. On the ether hand, the unwritten data amount (DAA) of the LUNA is 60. In this case, since the value of the unwritten data amount (DAA) of the LUNA and the value of the unwritten data amount (DAB) of the LUNB both exceed the occupation reserved capacity (TH 2 ), they are maintained as they are without being adjusted (corrected). 
     Therefore, the unwritten data amount (DAA) of the LUNA is less than or equal to the maximum occupiable capacity (TH 1 ), that is, DAA≤TH 1 , and the adjustment data amount determination condition holds. 
     On the other hand, the unwritten data total amount is 100, which is the actual unwritten data total amount (40+60) obtained by adding the DAA to the DAB. Therefore, since the unwritten data total amount is less than or equal to the buffer capacity (MAX_CAP), that is, DAA+DAB≤MAX_CAP, the adjustment data total amount determination condition holds. 
     In the example shown in  FIG. 14 , both the adjustment data amount determination condition and the adjustment data total amount determination condition hold, so that the command completion notification condition holds. That is, the storage area of the write data can be reserved in the PLP buffer  6   b  with a write command processing thread in the LUNA, which is the target LUN, and the LUNA command completion notification can be sent to the host  8 . 
     Thus, according to the magnetic disk device  1  of the embodiment, depending on whether the command completion notification condition with the write command processing thread in the target LUN holds, a storage area, in the PLP buffer  6   b , in which the write data is written (saved) can be reserved. Therefore, even when a plurality of the LUNs is included in one device, the PLP buffer  6   b  can be efficiently shared with the write command processing threads in respective LUNs. 
     For example, when many write commands are sent to one LUN, and the unwritten data amount with the processing thread for these write commands reaches the buffer capacity, there is a possibility in the related art that the write data of the unwritten data amount with the write command processing thread in another LUN cannot be saved in the PLP buffer  6   b . However, by sharing the PLP buffer  6   b  as in this embodiment, a storage area of the write data of the unwritten data amount with the write command processing threads in ail LUNs without unevenness can be reserved in the PLP buffer  6   b.    
     That is, since the unwritten data amount is adjusted (corrected) according to whether the data amount adjustment necessity condition holds, it is possible to reserve the storage area of the occupation reserved capacity for all the LUNs. Therefore, it is possible to share the PLP buffer  6   b  with a plurality of the LUNs without exhausting the PLP buffer  6   b  with one LUN and surely occupy the storage area of the occupation reserved capacity. At this time, the storage capacity, of the PLP buffer  6   b , that can be occupied by one LUN is suppressed to the maximum occupiable capacity. Therefore, the PLP buffer  6   b  can be shared by a plurality of the LUNs so that a predetermined amount of storage area can be occupied with the maximum occupiable capacity as the upper limit. As a result, the write data of the unwritten data amount can be efficiently saved when the power is lost. 
     In addition, after sharing the PLP buffer  6   b  in this manner, the host  8  is notified through the command completion notification that the storage area of the write data of the unwritten data amount is reserved in the PLP buffer  6   b . Therefore, it can be surely ensured that the write data for which the command completion notification was made can be saved in the PLP buffer  6   b  even when it is not written (recorded) to the disk  21  when power is lost after the notification. That is, it is possible to improve the data protection performance when the power is lost. 
     In each of the embodiments described above, the two LUNs (LUNA, LUNB) are allocated to the magnetic disk device  1 , but the number of the LUNs is not particularly limited, and may be one or may be may be three or more. 
     For example, as in a single actuator type magnetic disk device, even when only a single LUN (hereinafter referred to as a LUNS) is allocated, it is possible to determine whether the completion notification of the write command is made in the same buffer management process. 
     In this case, the command completion notification condition is determined using the unwritten data amount (DAS) of the LUNS and the buffer capacity (MAX_CAP) of the PLP buffer  6   b  as the determination parameters.  FIGS. 15 and 16  show specific examples of whether the command completion notification condition holds. In the example shown in  FIGS. 15 and 16 , the PLP buffer  6   b  has a buffer capacity (MAX_CAP) of 100. The target LUN is the LUNS. As described above, the examples shown in  FIGS. 15 and 16  correspond to modifications of the first embodiment. 
     In the example shown in  FIG. 15 , the unwritten data amount (DAS) of the LUNS is 80, which is less than or equal to the buffer capacity (MAX_CAP) (DAS≤MAX_CAP). That is, the PLP buffer  6   b  has a storage area in which the write data of the unwritten data amount (DAS) of the LUNS can be written (saved). Therefore, a storage area of the write data can be reserved in the PLP buffer  6   b  with a write command processing thread in the LUNS, which is the target LUN. As a result, the command completion notification condition holds, and the LUNS command completion notification can be sent to the host  8 . 
     In the example shown in  FIG. 16 , the unwritten data amount (DAS) of the LUNS is 110, which exceeds the buffer capacity (MAX_CAP), that is DAS&gt;MAX_CAP. Therefore, the storage area of the write data cannot be reserved in the PLP buffer  6   b  with the write command processing thread in the LUNS, which is the target LUN. As a result, the command completion notification condition does not hold, and the LUNS command completion notification cannot be sent to the host  8 . 
       FIG. 17  shows a specific example of the whether the command completion notification condition when the number of the LUNs is three, in other words, the number of non-target LUNs is two or more (the total number of the LUNs including the target LUN is three or more) holds. In the example shown in  FIG. 17 , the PLP buffer  6   b  has a buffer capacity (MAX_CAP) of 100, a maximum occupiable capacity (TH 1 ) of 60, and an occupation reserved capacity (TH 2 ) of 10. The target LUN is the LUNA, and the non-target LUNs are the LUNB and the LUNC. That is, the LUNA is currently attempting to issue a command completion notification by reserving a storage area of the write data in the PLP buffer  6   b  with a write command processing thread. On the other hand, in the LUNB and the LUNC, the storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread different from that of the LUNA, and the command completion notification is made. Thus, the example shown in  FIG. 17  corresponds to a modification of the third embodiment. 
     In the example shown in  FIG. 17 , the storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread in the LUNB, and the unwritten data amount (DAB) is 35. Further, the storage area of the write data is already reserved in the PLP buffer  6   b  with a write command processing thread in the LUNG, and the unwritten data amount (DAC) is 5. The unwritten data amount (DAA) of the LUNA is 60. Since the value exceeds the occupation reserved capacity (TH 2 ), the value of unwritten data amount (DAA) of the LUNA and the value of unwritten data amount (DAB) of the LUNB are maintained without adjustment. On the other hand, since the value of the unwritten data amount (DAC) of the LUNG is less than the occupation reserved capacity (TH 2 ), the value is adjusted (corrected) to the value of TH 2  to be 10. 
     Since the maximum occupiable capacity (TH 1 ) is 60 and the unwritten data amount (DAA) of the LUNA is less than or equal to this value, that is, DAA≤TH 1 , the adjustment data amount determination condition holds. That is, the PLP buffer  6   b  has a storage area in which the write data of the unwritten data amount (DAA) of the LUNA can be written (saved). 
     On the other hand, the unwritten data tonal amount is 105, which is the data amount (35+10+60) obtained by adding the actual DAA to the actual DAB and the adjusted DAC. Therefore, since the unwritten data total amount exceeds the buffer capacity (MAX_CAP), that is, DAA+DAB+DAC&gt;MAX_CAP, the adjustment data total amount determination condition does not hold. The data amount when an actual DAC is used is 100 (35+5+40), which is less than or equal to the buffer capacity (MAX_CAP). However, the adjustment data total amount determination condition does not hold because the adjusted value is used as the LUNG data unwritten amount. 
     In this way, in the example shown in  FIG. 17 , the adjustment data amount determination condition holds, but the adjustment data total amount determination condition does not hold, so that the command completion notification condition does not hold, and the LUNA command completion notification cannot be sent to the host  8 . 
     While certain embodiments have been described, these embodiments have been presented by way of example only, and are not intended to limit the scope of the inventions, indeed, the novel embodiments described herein may be embodied in a variety of other forms; furthermore, various omissions, substitutions and changes in the form of the embodiments described herein may be made without departing from the spirit of the inventions. The accompanying claims and their equivalents are intended to cover such forms or modifications as would fall within the scope and spirit of the inventions.