ELECTRONIC DEVICE, AND FILE SYSTEM OPERATING METHOD OF ELECTRONIC DEVICE

An electronic device includes, one or more processors; and memory storing instructions, that, when executed by the one or more processors, cause the electronic device to write files of an application to the memory; determine pinned files; classify hot files and cold files, from among remaining files that are not pinned, according to write patterns of the remaining files; store the pinned files and the cold files in a first area of the memory with a fixed size, and store the hot files in a second area of the memory with a variable size; determine, based on available storage space in the first area, files with changeable allocated block addresses in the first area; and move the files from the first area to the second area, and store the pinned files in a space of the first area that is generated based on moving the files.

BACKGROUND

The present disclosure relates to an electronic device including a memory and a file system operating method of the electronic device.

2. Description of Related Art

Recently developed electronic devices, such as a smart phone, a tablet PC, a portable multimedia player (PMP), personal digital assistant (PDA), a laptop personal computer, and a wearable device, may perform various functions (e.g., game, social network service (SNS), the Internet, multimedia, and photo and video shooting and execution) as well as mobility.

The electronic device may include a storage device such as a NAND flash memory or a solid state disk (SSD) to store a large amount of data to perform various functions.

The electronic device may write at least a part of data of an application to a main memory using a file system, which is a type of program module or software that may be executed by a processor. The electronic device may classify a type of files to be written using the file system at the time of writing the data of the application to the main memory and control the classified files to be separately stored in the memory.

SUMMARY

According to an aspect of the disclosure, an electronic device includes, one or more processors; and memory storing instructions, that, when executed by the one or more processors, cause the electronic device to write a plurality of files of an application to the memory in response to a file input request of the application; determine one or more pinned files, from among the plurality of files; classify one or more hot files and one or more cold files, from among a remaining plurality of files that are not pinned, according to a plurality of write patterns of the remaining plurality of files; store the one or more pinned files and the one or more cold files in a first area of the memory that has a fixed size, and store the one or more hot files in a second area of the memory that has a variable size, wherein the first area and the second area are separated by a partition; determine, based on available storage space in the first area being less than a predetermined level, one or more first files with allocated block addresses that are changeable, from among a first plurality of files stored in the first area; and move, from the first area to the second area, the one or more first files, and store the one or more pinned files in a space of the first area that is generated based on moving the one or more first files.

A hot file may be modified or deleted less than a cold file, and a pinned file may have an allocated block address that is determined to be unchangeable. The instructions, when executed by the one or more processors, may cause the electronic device to identify whether a file is stored in the second area based on receiving, from the application, information indicating that a file block stored in the memory corresponds to the file, and the file is to have an attribute indicating the file is pinned; and move the file to the first area based on identifying that the file is stored in the second area, and designate the attribute to indicate the file is pinned.

The instructions, when executed by the one or more processors, may cause the electronic device to preferentially store the one or more hot files in the second area; and store at least one of the one or more hot files in the first area based on determining there is insufficient storage space in the second area.

The instructions, when executed by the one or more processors, may cause the electronic device to preferentially store the one or more cold files in the first area; and store at least one of the one or more cold files in the second area based on determining there is insufficient storage space in the first area.

The instructions, when executed by the one or more processors, may cause the electronic device to store the one or more pinned files in the first area; and move at least one of the one or more hot files in a first space in the first area to the second area based on determining there is insufficient storage space in the first area, and move at least one of the one or more pinned files into the first space.

The instructions, when executed by the one or more processors, may cause the electronic device to determine whether no hot files are stored in the first area or whether there would be insufficient storage space available to store the one or more pinned files in the first area after moving the one or more hot files to the second area; and move at least one of the one or more cold files from a second space of the first area to the second area based on determining there is insufficient storage space available to store the one or more pinned files in the first area, and store the one or more pinned files in the second space.

The one or more hot files may include at least one of a temporary storage file or a cache file, and the one or more cold files may include at least one of a multimedia file or an application execution file.

The instructions, when executed by the one or more processors, may cause the electronic device to store the plurality of files in the first area, irrespective of attributes of the plurality of files, based on determining the available storage space in the first area exceeds the predetermined level; and store the one or more hot files in the second area based on determining the available storage space in the first area is less than the predetermined level.

The plurality of write patterns may include at least one of file size, whether a file is modified (dirty page), a time (modification time) when the file was modified, a time interval (modification interval) at which the file was modified, a count (fsync) with which a system called the file, a size (chunk size) of a portion of the file being modified, an extension of the file, a directory name in which the file is stored, or whether a predetermined file system is used.

The plurality of write patterns may further include an overwrite count indicating a number of times a middle portion of the file is modified, and the instructions, when executed by the one or more processors, may cause the electronic device to determine the number to be frequent based on the overwrite count exceeding a first threshold, and classify the file as a hot file, and determine the number to be infrequent based on the overwrite count being less than a second threshold, and classify the file as a cold file.

According to an aspect of the disclosure, a non-transitory computer-readable recording medium having instructions recorded thereon, that, when executed by one or more processors, cause the one or more processors to write a plurality of files of an application to memory in response to a file input request of the application; determine one or more pinned files from among the plurality of files; classify one or more hot files and one or more cold files, from among a remaining plurality of files that are not pinned, according to a plurality of write patterns of the plurality of files; store the one or more pinned files and the one or more cold files in a first area of the memory that has a fixed size, and store the one or more hot files in a second area of the memory that has a variable size; determine, based on available storage space in the first area being less than a predetermined level, one or more first files with allocated block addresses that are changeable, from among a first plurality of files stored in the first area; and move, from the first area to the second area, the one or more first files, and store the one or more pinned files in a space of the first area that is generated based on moving the one or more first files.

A hot file may be modified or deleted less than a cold file, and a pinned file may have an allocated block address that is determined to be unchangeable. The instructions, when executed by the one or more processors, may cause the one or more processors to identify whether a file is stored in the second area based on receiving, from the application, information indicating that a file block stored in the memory corresponds to the file, and the file is to have an attribute indicating the file is pinned; and move the file to the first area based on identifying that the file is stored in the second area, and designate the attribute to indicate the file is pinned.

The instructions, when executed by the one or more processors, may cause the one or more processors to preferentially store the one or more hot files in the second area; and store at least one of the one or more hot files in the first area based on determining there is insufficient storage space in the second area.

The instructions, when executed by the one or more processors, may cause the one or more processors to preferentially store the one or more cold files in the first area, and store at least one of the one or more cold files in the second area based on determining there is insufficient storage space in the first area.

The instructions, when executed by the one or more processors, may cause the one or more processors to store the one or more pinned files in the first area; and move at least one of the one or more hot files stored in a first space in the first area to the second area based on determining there is insufficient storage space in the first area, and move at least one of the one or more pinned files into the first space.

The instructions, when executed by the one or more processors, may cause the one or more processors to determine whether no hot files are stored in the first area or whether there would be insufficient storage space available to store the one or more pinned files in the first area after moving the one or more hot files to the second area; and move at least one of the one or more cold files inform a second space of the first area to the second area based determining there is insufficient storage space available to store the one or more pinned files in the first area, and store the one or more pinned files in the second space.

The one or more hot files may include at least one of a temporary storage file or a cache file, and the one or more cold files may include at least one of a multimedia file or an application execution file.

The instructions, when executed by the one or more processors, may cause the one or more processors to store the plurality of files in the first area, irrespective of attributes of the plurality of files, based on determining the available storage space in the first area exceeds the predetermined level; and store the one or more hot files in the second area based on determining the available storage space in the first area is less than the predetermined level.

The plurality of write patterns may include at least one of file size, whether a file is modified (dirty page), a time (modification time) when the file was modified, a time interval (modification interval) at which the file was modified, a count (fsync) with which a system called the file, a size (chunk size) of a portion of the file being modified, an extension of the file, a directory name in which the file is stored, or whether a predetermined file system is used.

The plurality of write patterns may further include an overwrite count indicating a number of times a middle portion of the file is modified, and the instructions, when executed by the one or more processors, may cause the one or more processors to determine the number to be frequent based on the overwrite count exceeding a first threshold, and classify the file as a hot file; and determine the number to be infrequent based on the overwrite count being less than a second threshold, and classify the file as a cold file.

DETAILED DESCRIPTION

The embodiments described in the disclosure, and the configurations shown in the drawings, are only examples of embodiments, and various modifications may be made without departing from the scope and spirit of the disclosure.

FIG. 2 illustrates a file classification operation of the electronic device according to an embodiment.

The electronic device (e.g., the electronic device 101 of FIG. 1) may include a processor (e.g., the processor 120 of FIG. 1) and a memory 220. The processor 120 may classify and store files in the memory 220 in response to a file write request of at least one application. The processor 120 may classify files as either hot files or cold files according to pre-defined rules 201 on a file system 225 in the memory 220. The hot files may mean files that are relatively frequently modified and/or deleted compared to the cold files. The cold files may mean files that are relatively infrequently modified and/or deleted compared to the hot files. The hot file may include, for example, DB, xml files, and the cold file may include, for example, media files such as photo and video. The pre-defined rules 201 may include at least one of a rule set according to a method of predicting the possibility that files will be changed based on, for example, file extensions (.xml,.db,.jpg,.mp4, for example), a rule set according to a method of predicting the possibility that files will be changed based on directory characteristics specified for each OS, or a rule set according to a method of predicting the possibility that files will be changed based on a block write size, for example.

The file system 225 may mean a program module (e.g., the program module 140 of FIG. 1) that may be executed by the processor 120. The electronic device may separately store a plurality of files in the memory 220 using the file system 225.

The processor 120 may identify whether the file classification information and the file data on the application match the file data stored in the memory 220 using a writeback thread module 203 of the file system 225, and when the file data in the memory 220 does not match the file data on the application, control to perform the writeback.

The writeback may mean an operation of updating only a cache of the memory 220 when writing the file data. The processor 120 may control to update only the cache when writing the file data, and write the file data to a main memory device or an auxiliary memory device including the memory 320.

The electronic device 101 may use a write pattern of at least a part of a time period between the time when the files are written to a page cache in the memory 220 and the time when the files are stored in the memory 220 to separately store files (hot files) that are frequently modified and deleted and files (cold files) that are infrequently changed after storage.

The electronic device 101 may classify the type of files using the file system 225 and separately store the files in the memory 220.

The electronic device 101 may use the write pattern from the time when the files are written to the page cache to the time when the files are stored in the storage to separately store the files (hot files) that are frequently modified and deleted and the files (cold files) that are infrequently changed after the file storage.

The technology for separately storing the hot files and the cold files are being handled by various methods in the fields of the memory 220 and the file system 225. The reason is that, when separately storing the hot files and the cold files, the NAND storage or the file system may refer to the information to minimize a garbage collection operation, or when storing the cold files with a relatively larger size compared to the hot files, data blocks are continuously stored to minimize fragmentation, thereby optimizing the file storage performance and the NAND storage lifespan.

The electronic device 101 may support some files (e.g., pinned files) with file attributes of which the block movement is restricted. An application may manage a location where file data blocks are stored within the application. The application may directly transmit read and write requests to a block address of a storage device without going through the file system for the read and write requests of the data block. When the data block addresses of the pinned files are arbitrarily changed on the file system 225, a problem of accessing an incorrect data address on the application may occur. To prevent this problem, the electronic device 101 may store the pinned files in a space where the pinned files are not reclaimed and control the data block addresses of the pinned files not to be arbitrarily changed on the file system 225.

FIG. 3 is a block diagram illustrating a configuration of the electronic device according to an embodiment.

Referring to FIG. 3, an electronic device 300 may include a processor 310 and a memory 320, and some of the illustrated components may be substituted. The electronic device 300 may further include at least some of the components and/or functions of the electronic device 101 of FIG. 1. At least some of the components of the illustrated (or not illustrated) electronic device may be operatively, functionally, and/or electrically connected to each other.

According to an embodiment, the processor 310 is a component capable of performing calculations or data processing related to control and/or communication of each component of the electronic device 300, and may be composed of one or more processors. The processor 310 may include at least some of the components and/or functions of the processor 120 of FIG. 1.

According to an embodiment, the calculation and data processing functions that may be implemented by the processor 310 on the electronic device 300 are not limited. Characteristics related to the control of the file system 325 in the memory 320 will be described in detail. The operations of the processor 310 may be performed by loading the instructions stored in the memory 320 (e.g., the memory 130 of FIG. 1). The file system 325 structure may mean a structure for storing or organizing files or data so that the electronic device 300 may discover and access the files or data. The file system 325 according to an embodiment may configure the file system structure to store and manage files and directories in the memory 320.

At least one memory 320 may include the volatile memory 132 of FIG. 1, and may also include the nonvolatile memory 134 of FIG. 1. The memory 320 may include a volatile memory such as a dynamic random access memory (DRAM), a static RAM (SRAM), or a synchronous dynamic RAM (SDRAM). The memory 320 may include at least one of one time programmable ROM (OTPROM), PROM, EPROM, EEPROM, mask ROM, flash memory, hard drive, or solid state drive (SSD). The memory 320 is the non-volatile memory and may include a large capacity storage device. For example, the memory 320 may include at least one of one time programmable ROM (OTPROM), PROM, EPROM, EEPROM, mask ROM, flash ROM, hard drive, or solid state drive (SSD). The memory 320 may store various file data, and the stored file data may be updated according to the operation of the processor 310.

According to an embodiment, the file system 325 may mean a system that can be used by intercepting a system call at a kernel level without a separate daemon. The daemon may mean a background process that is executed when the system is first operated. The file system 325 may wait for the user's request while the daemon is stored in the memory 320 and then recognize the user's request when the user's request occurs.

According to an embodiment, the file system 325 may provide files in response to a request from an application layer. The file system 325 may be located on a kernel layer. The operation of providing the files may mean an operation of opening and reading the requested files or reading the already open files to transmit the read open files to the application layer. The operation of opening the files may mean an operation of finding names of the files in the storage device and preparing to read and/or write the files in the application layer. The operation of reading the files may mean an operation of loading the open file data into the memory 320. The loading may mean an operation of fetching a program itself and resources for the operation from the auxiliary memory device (e.g., hard disk) to the main memory device (e.g., memory).

According to an embodiment, the file system 325 may read the requested file and provide the files to the application layer in response to the request of the application layer when the requested file exists on an upper file system in the memory 320, and read the files on the nonvolatile memory and provide the files to the application layer when the requested files do not exist on the upper file system.

According to an embodiment, the processor 310 may execute various types of software (e.g., the program 140). The memory 320 may include the file system 325. The file system 325 is a program module stored in the memory 320 and may be operated by the processor 310.

According to an embodiment, the processor 310 may store data in the form of the files in the memory 320 through the file system 325. The file system 325 may mean a data structure or system that the processor 310 manages to store data in the memory 320. The electronic device 300 may use the file system 325 to write data to the memory 320 or efficiently read the data stored in the memory 320. In an embodiment, the file system 325 is described assuming that the file system 325 is implemented as a flash friendly file system (F2FS), but the form of the file system 325 is not limited to the F2FS, and may include other forms of file systems. The F2FS may mean a file system optimized for a NAND flash memory based on log-based storage.

According to an embodiment, the memory 320 may include a first area 331 in which a first file or the cold files are stored. The memory 320 may include a second area 332 in which a second file or the hot files are stored. The first file or the cold files may mean files that are relatively infrequently modified and/or deleted compared to the hot files. The second file or the hot files may mean files that are relatively frequently modified and/or deleted compared to the cold files.

According to an embodiment, the file system 325 may include a writeback thread module (e.g., the writeback thread module 203 of FIG. 2). The writeback thread module 203 may detect a request from an application to write files to the file system 325 and monitor key characteristics (hereinafter referred to as a ‘write pattern’ or ‘first pattern’) of the write operation. The writeback thread module 203 may temporarily store the write pattern of the file being monitored in a file object (not illustrated) in the memory 320. The write pattern may include at least one of the file size, whether the files are modified (dirty page), a time (modification time) when the files are modified, a time interval (modification interval) at which the files are modified, a count (fsync) with which the system calls the files, a size (chunk size) of a portion being modified on the files, extensions of the files, directory names in which the files are stored, and whether a predetermined file system is used.

According to an embodiment, features of the write patterns of the files may include at least one of an overwrite count, an append count, a write chunk, or a system call count (fsync).

The overwrite count may mean the number of times some of the files are modified in the middle. For example, the processor 310 may classify the files as the overwrite count when storing the files in the case where some cells in an Excel file are modified. When the overwrite count of the files is relatively large, the processor 310 may determine that the files are frequently modified and classify the files as being close to the hot files.

For example, when the overwrite count is greater than a first threshold, the processor 310 may determine that the files are frequently modified and may classify the files as being hot files. When the overwrite count is less than a second threshold, the processor 310 may determine that the files are infrequently modified and may classify the files as being cold files.

The append count may mean the number of times other data is newly added to the existing files. For example, the processor 310 may classify files as the append count when storing the files in the case where new data is added beyond the level of the files being partially modified in a jpg file. When the append count of the files is relatively large, the processor 310 may determine that new contents are often added to the files and may classify the files as being close to the cold files.

The write chunk may mean a file size unit stored in an operation of writing the files to the memory 320. For example, when the write chunk is relatively small, the processor 310 may determine that a small number of writes are performed in a one-time write operation and classify the files as being close to the hot files. Conversely, when the write chunk is relatively large, the processor 310 may determine that a large number of writes are performed in a one-time write operation and classify the files as being close to the cold files.

The system call count (fsync) may mean the number of times the files recorded in the cache of the memory 320 are written to the non-volatile memory. For example, when the fsync is lower than a predetermined value, the processor 310 may determine that the files recorded in the memory 320 are files that are written relatively less frequently. In other words, when the fsync is lower than the predetermined value, the processor 310 may classify the files as the cold files that are infrequently modified. Conversely, when the fsync is higher than the predetermined value, the processor 310 may classify the files as the hot files that are relatively frequently modified.

According to an embodiment, the processor 310 may classify whether files are the hot files or the cold files based on the features of at least one write pattern described above.

FIG. 4A is a diagram illustrating a situation of shrinking a partition on the file system.

Referring to FIG. 4A, the electronic device (e.g., the electronic device 300 of FIG. 3) may support some files (e.g., pinned files) with the file attribute of which the block movement is restricted. The electronic device 300 may divide an area on the memory (e.g., the memory 320 of FIG. 3) and store files in different areas according to their attributes. A first area (e.g., the first area 331 of FIG. 3) 401 and a second area (e.g., the second area 332 of FIG. 3) 402 may be divided by a partition on the memory 320. According to an embodiment, the electronic device 300 may generate a new partition or support a shrink operation of some partitions to expand spaces of other partitions. The electronic device 300 may reclaim some areas (e.g., the second area 402) to shrink the partition. The reclaimed space (e.g., the second area 402) may be an available space where the files are not stored. The files stored in the reclaimed space (e.g., the second area 402) may be deleted after the reclamation operation of the electronic device 300. The electronic device 300 may move the files stored in the reclaimed space (e.g., the second area 402) to the non-reclaimed space (e.g., the first area 401) to prevent files from being deleted or lost. The movement of the files may incur costs, and when the number of files moved increases, the files are deleted during the movement of the files or are left in the space that is reclaimed without being moved, so the number of files being deleted may increase.

The electronic device 300 and the file system operating method of the electronic device 300 according to an embodiment may reduce the number of files stored in the reclaimed space (e.g., the second area 402) when shrinking the partition, and reduce costs due to the movement of the files. The electronic device 300 according to an embodiment may mainly arrange the files (e.g., the hot files) expected to be deleted soon according to the file attribute in the reclaimed space (e.g., the second area 402), and control the data loss to be minimized even if there are the files that are left in the reclaimed space and deleted. The file system operating method of the electronic device for minimizing the costs and data loss due to the movement of the files will be described.

FIG. 4B is a diagram illustrating the file system of the electronic device according to an embodiment.

The first area 401 may mean a non-reclaimable extent when shrinking the partition. The processor (e.g., the processor 310 of FIG. 3) may preferentially store the pinned files and the cold files in the first area 401. The pinned files may mean the files with the file attributes of which the block movement is restricted. The cold files may mean the files that are relatively infrequently modified and/or deleted compared to the hot files. The cold file may include, for example, media files such as photo and video. This is only an example, and the type of cold files is not limited thereto, and the cold files may include any file that is infrequently modified and/or deleted.

The memory 320 may include the non-reclaimable first area 401 and the reclaimable second area 402. The second area 402 may further include a plurality (e.g., N) of areas 402_1, 402_2, . . . , 402_N-1, and 402_N. The areas 402_1, 402_2, . . . , 402_N-1, and 402_N within the second area 402 may have priorities in terms of the reclamation. For example, when shrinking the partition, the 2-Nth area 402_N may be reclaimed first, and the 2-1th area 402_1 may be reclaimed last. The number or priority of areas within a reclaimable extent is not fixed and may vary depending on the settings.

FIG. 5 is a diagram illustrating a situation of allocating a file block on the file system of the electronic device according to an embodiment.

The processor (e.g., the processor 310 of FIG. 3) may receive a write request for pinned files 505 from an application and store the pinned files 505 in the memory (e.g., the memory 320 of FIG. 3). Since the pinned files 505 have the file attributes of which the block movement is restricted, the processor 310 may allocate the pinned files to the non-reclaimable first area 401. The processor 310 may allocate the pinned files 505 to the non-reclaimable first area 401, thereby reducing costs due to the movement of the files and preventing the loss of the pinned files 505 that may occur during the movement of the files. The application may designate files as the pinned files based on determining to obtain the attributes of the pinned files.

According to an embodiment, the processor 310 may identify whether there is a sufficient space to store the pinned files 505 in the first area 401. Based on the determination that there is the insufficient space to store the pinned files 505 in the first area 401, the processor 310 may move some files stored in the first area 401 to the second area 402 to secure the storage space. The second area 402 means a reclaimable area in the operation of shrinking the partition. The processor 310 may move the hot files 507, which are relatively frequently modified and/or deleted compared to the cold files, to the second area 402. The processor 310 may store the pinned files 505 in the space generated while moving the hot files on the first area 401.

According to an embodiment, the processor 310 may identify whether the files are stored in the second area 402 based on receiving, from the application, a signal or information indicating that the file block stored in the memory 320 has the attributes corresponding to the pinned files 505. The processor 310 may move the files to the first area 401 and designate the attributes corresponding to the pinned files 505 based on identifying that the files are stored in the second area 402. When the files stored in the reclaimable second area 402 are changed to have the attributes of the pinned files, the processor 310 may move the files to the first area 401 in the operation of reclaiming the partition later. Since the movement of the files incur costs and poses a risk of the file loss, the processor 310 may move the files to the first area 401 in advance and designate the attributes corresponding to the pinned files 505.

According to an embodiment, the processor 310 may preferentially store the hot files in the second area 402, and store the hot files in the first area 401 based on the insufficient storage space in the second area 402.

According to an embodiment, unlike the first area 401, the second area 402 may experience the area shrink due to the partition shrink. In the process of shrinking the second area 402, the movement or deletion of the files may occur. It may be advantageous for the processor 310 not to store the files in the second area 402 in terms of reducing costs or the risk of the file loss. For this reason, the processor 310 may store files of all attributes in the first area 401 until the available space in the first area 401 becomes less than the predetermined level (e.g., 20%), and allocate some files (e.g., the hot files 507) with attributes to the second area 402 on the basis that the available space in the first area 401 becomes less than the predetermined level. The predetermined level (e.g., 20%) is only an example and is not fixed, and may vary according to the settings.

According to an embodiment, the processor 310 may preferentially store the cold files in the first area 401, and store the cold files in the second area 402 based on the insufficient storage space in the first area 401.

The processor 310 may store the pinned files 505 in the first area 401, move at least some of the hot files 507 stored in the first area 401 to the second area 402 based on the insufficient storage space in the first area 401, and store the pinned files 505 in the space in the first area 401 in which the hot files 507 are stored.

The processor 310 may identify whether there is no hot files stored in the first area 401 or whether there is the insufficient available space to store the pinned files 505 in the first area 401 even after moving the hot files 507 stored in the first area 401, move at least some of the cold files stored in the first area 401 to the second area 402 based on the insufficient available space to store the pinned files 505 in the first area 401, and store the pinned files 505 in the space on the first area 401 in which the cold files are stored.

FIG. 6 is a diagram illustrating a situation of removing the file block on the file system of the electronic device according to an embodiment.

FIG. 610 illustrates a situation in which files (e.g., hot files 630 and cold files 632) are stored without dividing between the non-reclaimable first area 401 and the reclaimable second area 402. In the FIG. 610, the cold files 632 may be stored in an area with a high reclamation priority on the second area 402. The cold files 632 on the area being shrunk may be deleted in the partition shrink situation. The processor (e.g., the processor 310 of FIG. 3) may move the cold files 632 to the non-reclaimable first area 401 to prevent the deletion of the cold files 632. Costs may be incurred during the movement of the files. Some or all of the cold files 632 being moved may be lost in the situation where the available space in the first area 401 is insufficient.

The electronic device (e.g., the electronic device 300 of FIG. 3) and the file system operating method of the electronic device 300 according to an embodiment may reduce costs and the risk of file loss during the movement of the files. This will be described in FIG. 620. In the FIG. 620, the processor 330 may classify the files based on the file attributes, and control cold files 632 to be stored in the first area 401 and hot files 630 to be stored in the second area 402. The electronic device 300 according to an embodiment may control the files not to be stored in the reclaimable second area 402, or control the hot files 630, which have a high probability of being deleted or invalidated within a short period of time, to be stored. When shrinking the partition, only valid files (or file blocks) may be a movement target. The valid files may include, for example, the cold files 632 or the pinned files (e.g., the pinned files 505 of FIG. 5). The electronic device 300 according to an embodiment may control not to store the cold files 632 or the pinned files 505 in the second area 402. Compared to the FIG. 610, the electronic device 300 according to an embodiment may store only invalid files (e.g., the hot files 630), which are not file move targets, in the second area 402 to reduce can reduce the number of files (or the number of file blocks) moved when shrinking the partition.

FIG. 7 is a flowchart of a file system operating method of the electronic device according to an embodiment.

The operations described with reference to FIG. 7 may be implemented based on instructions that may be stored in a computer recording medium or a memory (e.g., the memory 320 of FIG. 3). An illustrated method 700 may be executed by the electronic device (e.g., the electronic device 300 of FIG. 3) described with reference to FIGS. 1 to 6 above, and reference may be made to the descriptions of FIGS. 1 to 6 for additional implementation details. The order of each operation of FIG. 7 may be changed, and some operations may be performed simultaneously.

In operation 710, the processor (e.g., the processor 310 of FIG. 3) may determine whether the files are the pinned file while writing the application file on the memory (e.g., the memory 320 of FIG. 3). The pinned files may mean the files with the file attributes of which the block movement is restricted. The application may designate the files as the pinned files based on determining to obtain the attributes of the pinned files. The processor 310 may identify the attributes of the files to determine whether the files requested to be written to the application have the attributes of the pinned files.

In operation 720, the processor 310 may classify the files as either the hot files or the cold files according to the write patterns of the files. The processor 310 may classify the files as either the hot files or the cold files according to the write patterns of the files on the basis that the files requested to be written to the application do not have the attributes of the pinned files. The hot files may mean the files that are relatively frequently modified and/or deleted compared to the cold files. The cold files may mean the files that are relatively infrequently modified and/or deleted compared to the hot files. The write pattern may include at least one of the file size, whether the files are modified (dirty page), the time (modification time) when the files are modified, the time interval (modification interval) at which the files are modified, the count (fsync) with which the system calls the files, the size (chunk size) of a portion being modified on the files, the extensions of the files, the directory names in which the files are stored, and whether the file system is used. According to an embodiment, the features of the write patterns of the files may include at least one of the overwrite count, the append count, the write chunk, or the system call count (fsync).

The overwrite count may mean the number of times some of the files are modified in the middle. For example, the processor 310 may classify the files as the overwrite count when storing the files in the case where some cells in the Excel file are modified. When the overwrite count of the files is relatively large, the processor 310 may determine that the files are frequently modified and classify the files as being close to the hot files.

For example, when the overwrite count is greater than a first threshold, the processor 310 may determine that the files are frequently modified and may classify the files as being hot files. When the overwrite count is less than a second threshold, the processor 310 may determine that the files are infrequently modified and may classify the files as being cold files.

The append count may mean the number of times other data is newly added to the existing files. For example, the processor 310 may classify the files as the append count when storing the files in the case where new data is added beyond the level of the files being partially modified in the jpg file. When the append count of the files is relatively large, the processor 310 may determine that new contents are often added to the files and may classify the files as being close to the cold files.

The write chunk may mean the file size unit stored in the operation of writing the files to the memory 320. For example, when the write chunk is relatively small, the processor 310 may determine that a small number of writes are performed in a one-time write operation and classify the files as being close to the hot files. Conversely, when the write chunk is relatively large, the processor 310 may determine that a large number of writes are performed in a one-time write operation and classify the files as being close to the cold files.

The system call count (fsync) may mean the number of times the files recorded in the cache of the memory 320 are written to the non-volatile memory. For example, when the fsync is relatively low, the processor 310 may determine that the files recorded in the cache of the memory 320 are the files that are written relatively few times. When the fsync is relatively low, the processor 310 may determine that the files are infrequently modified and classify the files as being close to the cold files. Conversely, when the fsync is relatively high, the processor 310 may determine that the files are relatively frequently modified and classify the files as being close to the hot files. When the fsync is less than a first level, the processor 310 may determine that the files are infrequently modified and classify the files as being close to the cold files. For example, when the fsync is less than 3, the processor 310 may determine that the files are infrequently modified and classify the files as being close to the cold files. The value or the first level of the fsync may not be limited thereto, and may be determined by developer's settings or may be determined by training multiple files through machine learning.

According to an embodiment, the processor 310 may classify whether the files are the hot files or the cold files based on the features of at least one write pattern described above.

In operation 730, the processor 310 may store the pinned files and the cold files in the first area (e.g., the first area 401 of FIG. 4A) of which the size is fixed, and store the hot files in the second area (e.g., the second area 402 of FIG. 4A) of which the size may vary. The first area 401 may mean a non-reclaimable extent when shrinking the partition. The processor (e.g., the processor 310 of FIG. 3) may preferentially store the pinned files and the cold files in the first area 401. The cold file may include, for example, media files such as photo and video. This is only an example, and the type of cold files is not limited thereto, and the cold files may include any file that is infrequently modified and/or deleted.

According to an embodiment, the processor 310 may preferentially store the hot files in the second area 402, and store the hot files in the first area 401 based on the insufficient storage space in the second area 402.

In operation 740, the processor 310 may determine the files of which the allocated block address is changeable among the files stored in the first area 401 based on identifying that there is no available space in the first area 401.

According to an embodiment, unlike the first area 401, the second area 402 may experience the area shrink due to the partition shrink. In the process of shrinking the second area 402, the movement or deletion of the files may occur. It may be advantageous for the processor 310 not to store the files in the second area 402 in terms of reducing costs or the risk of the file loss. For this reason, the processor 310 may store files of all attributes in the first area 401 until the available space in the first area 401 becomes less than the predetermined level (e.g., 20%), and allocate some files (e.g., the hot files) with attributes to the second area 402 on the basis that the available space in the first area 401 becomes less than the predetermined level. The predetermined level (e.g., 20%) is only an example and is not fixed, and may vary according to the settings.

According to an embodiment, based on the determination that there is the insufficient space to store the pinned files in the first area 401, the processor 310 may move some files stored in the first area 401 to the second area 402 to secure the storage space. The second area 402 means the reclaimable area in the operation of shrinking the partition. The processor 310 may move the hot files, which are relatively frequently modified and/or deleted compared to the cold files, to the second area 402.

In operation 750, the processor 310 may move the files of which the block addresses are changeable from the first area to the second area, and store the pinned files in the space in the first area, generated by the movement of the files of which the block addresses are changeable. The processor 310 may store the pinned files 505 in the space generated while moving the hot files on the first area 401.

The electronic device may include the memory including the first area and the second area separated by the partition and the processor. The processor may write the files of the application to the memory in response to the file input request of the application, determine whether the files are the pinned files, classify the files as either the hot files or the cold files according to the write patterns of the files on the basis that the files are not the pinned files, store the pinned files and the cold files in the first area of which the size is fixed and store the hot files in the second area of which the size varies, determine, on the basis that the available space in the first area is less than the predetermined level, the files of which the allocated block addresses are changeable from among the files stored in the first area, and move, from the first area to the second area, the files of which the block addresses are changeable and store the pinned files in the space in the first area, generated by the movement of the files of which the block addresses are changeable.

The hot files are the files that are frequently modified and/or deleted compared to the cold files, the cold files are the files that are infrequently modified and/or deleted compared to the hot files, the pinned files means the files of which the allocated block addresses are determined unchangeable, and the processor may identify whether the files are stored in the second area based on receiving the signal or information from the application indicating that the file block stored in the memory has the attributes corresponding to the pinned files, move the files to the first area based on identifying that the files are stored in the second area, and designate the attributes corresponding to the pinned files. The processor may preferentially store the hot files in the second area, and store the hot files in the first area based on the insufficient storage space in the second area. The processor may preferentially store the cold files in the first area, and store the cold files in the second area based on the insufficient storage space in the second area.

The processor may store the pinned files in the first area, and move at least some of the hot files stored in the first area to the second area based on the insufficient storage space in the first area, and store the pinned files in the space in the first area in which the hot files are stored.

The processor may identify whether there is no hot files stored in the first area or whether there is the insufficient available space to store the pinned files in the first area even after moving the hot files stored in the first area, move, based on the insufficient available space to store the pinned files in the first area, at least some of the cold files stored in the first area to the second area, and store the pinned files in the space in the first area in which the cold files are stored.

The hot files may include temporary storage files or cache files, and the cold files may include multimedia files or application executable files.

The processor may store all the files of the attributes in the first area on the basis that the size of the available space in the first area exceeds the predetermined level, and store the hot files in the second area on the basis that the size of the available space in the first area is less than the predetermined level.

The write pattern may include at least one of the file size, whether the files are modified (dirty page), the time (modification time) when the files are modified, the time interval (modification interval) at which the files are modified, the count (fsync) with which the system calls the files, the size (chunk size) of a portion being modified on the files, the extensions of the files, the directory names in which the files are stored, and whether the predetermined file system is used.

The write pattern may include the overwrite count which means the number of times some of the files are modified in the middle, and when the overwrite count of the files is relatively large, the processor may determine that the files are frequently modified and classify the files as being close to the hot files, and when the overwrite count of the files is relatively small, the processor may determine that the number of times the files are modified is small and classify the files as being close to the cold files.

For example, when the overwrite count is greater than a first threshold, the files may be determined to be frequently modified and may be classified as hot files. When the overwrite count is less than a second threshold, the files may be determined to be infrequently modified and may be classified as cold files.

The various embodiments merely provide examples to facilitate an understanding of the disclosure and are not intended to limit the scope of the disclosure. The scope of the disclosure should be interpreted as including all changes or modifications derived based on the technical idea of an embodiment, in addition to the embodiments disclosed herein.