Memory system and control method
According to one embodiment, a memory system is connectable to a host. The memory system includes a nonvolatile memory and a controller. The nonvolatile memory includes a plurality of blocks. The controller is electrically coupled to the nonvolatile memory. The controller controls the nonvolatile memory. When receiving, from the host, a first command for changing a state of an allocated block to a reallocatable state in a case where a second command that is yet to be executed or being executed involving read of data from the allocated block has been received from the host, the controller changes the state of the allocated block to the reallocatable state after the second command is finished.
1 . A memory system connectable to a host, comprising:
a nonvolatile memory including a plurality of blocks, each of the plurality of blocks being a unit of a data erase operation, the plurality of blocks including at least a first block; and
a controller electrically coupled to the nonvolatile memory and configured to:
in response to receiving, from the host, a first command for changing a state of the first block from a first state to a second state, the first state being a state in which the host can designate the first block as a write destination, the second state being a state in which the host cannot designate the first block as the write destination and cannot read any valid data from the first block,
determine whether a read operation to the first block is pending or not; and
in a case where the read operation to the first block is pending, suspend to change the state of the first block from the first state to the second state until the read operation to the first block is finished.
2 . The memory system of claim 1 , wherein
the controller is further configured to change the state of the first block from the first state to the second state after the read operation to the first block is finished.
3 . The memory system of claim 1 , wherein
the controller is further configured to, in response to receiving the first command while the read operation to the first block is pending, notify the host of an error to the first command.
4 . The memory system of claim 1 , wherein
the controller is further configured to:
manage a counter for the first block, the counter showing the number of pending read operations to the first block; and
determine, based on a value of the counter, whether the read operation to the first block is pending or not.
5 . The memory system of claim 1 , wherein
the controller is further configured to:
manage a queue for storing a plurality of commands that are to be transmitted to the nonvolatile memory; and
determine, by searching the queue, whether the read operation to the first block is pending or not.
6 . The memory system of claim 1 , wherein
the controller is further configured to, in response to receiving, from the host, a second command for allocating the first block to the host, change the state of the first block from the second state to the first state.
7 . The memory system of claim 1 , wherein
the read operation to the first block is pending when the read operation to the first block is not yet started to be executed or the read operation to the first block is being executed.
8 . The memory system of claim 1 , wherein
the controller is configured to, in response to receiving, from the host, a third command for reading data from the nonvolatile memory, execute the read operation to the first block.
9 . The memory system of claim 1 , wherein
the controller is configured to execute the read operation to the first block for a garbage collection.
10 . The memory system of claim 1 , wherein
the controller is further configured to:
manage a plurality of block groups each including at least two of the plurality of blocks; and
in response to receiving, from the host, the first command that designates one of the plurality of block groups, determine the first block from among the at least two of the plurality of blocks included in the one of the plurality of block groups, as a target of changing the state.
11 . A method of controlling a nonvolatile memory that includes a plurality of blocks, each of the plurality of blocks being a unit of a data erase operation, the plurality of blocks including at least a first block, the method comprising:
in response to receiving, from a host, a first command for changing a state of the first block from a first state to a second state, the first state being a state in which the host can designate the first block as a write destination, the second state being a state in which the host cannot designate the first block as the write destination and cannot read any valid data from the first block,
determining that a read operation to the first block is pending; and
in response to determining that the read operation to the first block is pending, suspending to change the state of the first block from the first state to the second state until the read operation to the first block is finished.
12 . The method of claim 11 , further comprising:
changing the state of the first block from the first state to the second state after the read operation to the first block is finished.
13 . The method of claim 11 , wherein
the first command is received while the read operation to the first block is pending, and the method further comprises:
in response to receiving the first command while the read operation to the first block is pending, notifying the host of an error to the first command.
14 . The method of claim 11 , further comprising:
managing a counter for the first block, the counter showing the number of pending read operations to the first block, wherein
whether the read operation to the first block is pending or not is determined based on a value of the counter.
15 . The method of claim 11 , further comprising:
managing a queue for storing a plurality of commands that are to be transmitted to the nonvolatile memory, wherein
whether the read operation to the first block is pending or not is determined by searching the queue.
16 . The method of claim 11 , further comprising:
receiving, from the host, a second command for allocating the first block to the host; and
in response to receiving the second command, changing the state of the first block from the second state to the first state.
17 . The method of claim 11 , wherein
the read operation to the first block is pending when the read operation to the first block is not yet started to be executed or the read operation to the first block is being executed.
18 . The method of claim 11 , further comprising:
receiving, from the host, a third command for reading data from the nonvolatile memory, wherein
the read operation to the first block is executed in response to receiving the third command.
19 . The method of claim 11 , wherein
the read operation to the first block is executed for a garbage collection.
20 . The method of claim 11 , further comprising:
managing a plurality of block groups each including at least two of the plurality of blocks; and
in response to receiving, from the host, the first command that designates one of the plurality of block groups, determining the first block from among the at least two of the plurality of blocks included in the one of the plurality of block groups, as a target of changing the state.