{'fraction_non_alphanumeric': 0.03046376400510566, 'fraction_numerical': 0.008112324492979718, 'mean_word_length': 4.7094736842105265, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
APEX: Adaptive Ext4 File System for Enhanced Data Recoverability in Edge Devices

Recently Edge Computing paradigm has gained significant popularity both in industry and academia. With its increased usage in real-life scenarios, security, privacy and integrity of data in such environments have become critical. Malicious deletion of mission-critical data due to ransomware, trojans and viruses has been a huge menace and recovering such lost data is an active field of research. As most of Edge computing devices have compute and storage limitations, difficult constraints arise in providing an optimal scheme for data protection. These devices mostly use Linux/Unix based operating systems. Hence, this work focuses on extending the Ext4 file system to APEX (Adaptive Ext4): a file system based on novel on-the-fly learning model that provides an Adaptive Recover-ability Aware file allocation platform for efficient post-deletion data recovery and therefore maintaining data integrity. Our recovery model and its lightweight implementation allow significant improvement in recover-ability of lost data with lower compute, space, time, and cost overheads compared to other methods. We demonstrate the effectiveness of APEX through a case study of overwriting surveillance videos by CryPy malware on Raspberry-Pi based Edge deployment and show 678% and 32% higher recovery than Ext4 and current state-of-the-art File Systems. We also evaluate the overhead characteristics and experimentally show that they are lower than other related works.


I. INTRODUCTION
Internet of Things (IoT) paradigm enables integration of different sensors, compute resources and actuators to perceive external environment and act to provide utility in different applications like healthcare, transportation, surveillance among others [1]. The original idea of providing enhanced Quality of Service (QoS), which is a measure of the performance of such services, was to provide distributed computation and computation on Cloud [2]. A new computing paradigm namely 'Fog Computing' leverages resources both at public cloud and the edge of the network. It provides resource abundant machines available at multi-hop distance and resource constrained machines close to the user. Several works have shown that Fog computing can provide better and cheaper solutions compared to only Cloud based approaches [3], [4]. Thus, many of such IoT systems have recently been realized using Edge/Fog computing frameworks [5]. Due to the increased usage of such devices and frameworks, there has been increasing interest in developing efficient techniques to provide improved QoS that such systems provide [6].
Edge is considered as a nontrivial extension of the cloud, therefore, it is inevitable that same security and privacy challenges will persist [7]. Many works in literature show that there exist new security threats in Edge paradigm which provide opportunities of developing more robust and better systems [8]. One of the most crucial security problems is the loss of critical data due to malicious entities [8]. Some ways used by hackers to corrupt, delete and steal such critical data include the usage of data stealing malwares, ransomwares, trojans, deleting or overwriting viruses. Most malware attacks have been based on stealing crucial data from the system and requesting ransom payments in return for the data. Unfortunately, according to a recent survey [9], the number of novel ransomwares/trojans has increased up to 50 times in the last decade amounting to millions of dollars of illicit revenue.
Preventing such attacks has not been popular in IoT. This is because it requires significant computation and space [10] that drastically increases the cost of IoT deployment which is unfavorable for users. Also, it has been shown that no matter what protection mechanisms are put in place, edge paradigms will be successfully attacked [11]. Thus, the detection and recovery from such attacks seems a critical requirement for Edge Computing domain. Due to increasing frequency of novel attacks and their types, detection is quite challenging [12]. Despite such challenges, there exist prior work that have high accuracy of detecting such attacks [13], [14] but only a few of them utilize the ability of policy based allocation to recover from such attacks. The ones that utilize policy based allocation schemes [14], [15] have significant overhead of read/write latencies, computation time, space requirement and limited recover-ability that are not feasible for Edge nodes. We discuss more limitations of such strategies in Section II and identify the scope of improvement in terms of proper allocation with mechanisms allowing faster, portable and more efficient recovery. Our work primarily focuses on recovery in Hard Disk Drives (HDD), Flash Media and Solid State Devices (SSD).
Most of the conventional file systems such as Ext, NTFS and exFAT do not allow the users to specifically tag blocks/clusters/sectors -deleted or unused independently [16] where a block in hard-disk is a group of sectors that the operating system can point to. Lack of such freedom limits the kernel to overwrite the data on random locations reducing recovery. Some optimizations exist but are proprietary and not customizable to user specific needs. This limits the currently available kernels to utilize the full potential of file allocation and tagging for efficient recovery. Even the file allocation and mapping with virtual tables is restricted to specific fixed algorithms. Allowing these algorithms to be recover-ability aware in allocating blocks/clusters to files can improve the amount of data that can be recovered from such file systems. Making these algorithms adaptive and equipped with some learning model can further lead to optimization absent in current systems. The proposed file system APEX (Adaptive Ext4), implements an adaptive file allocation policy that supports a wide diversity of platforms due to its portable implementation. It provides a significant improvement in recovery of files with low overheads. It is designed to be lightweight and easy to deploy in Edge/Fog computing frameworks, increasing their reliability and data protection. Another advantage is that it provides improved forensic based recovery for criminal investigations to expose evidence and hence catch hackers/invaders. The main contributions of our work are as follows: • We propose a lightweight, adaptive, portable and efficient file allocation system optimized for higher post deletion recovery which is flexible, robust and is independent of storage architecture • We provide a set of pre-optimized weights that need only slight variation of hyper-parameters dependent on usage and thus low adapting time for new scenarios • We develop a prototype file system APEX and show its efficacy on a real life scenario for malicious deletion/overwriting of video surveillance footage. The rest of the paper is organized as follows. In Section II, we provide related works and compare them with ours. In Section III we first provide a basic recover-ability aware allocation mechanism and describe a heuristic based block ranking method that can optimize post-deletion data recovery. We then improve our heuristic measure by updating it dynamically to prioritize files based on the user's file access characteristics in Section IV and also provide model level details of a Disk Simulator for learning the weights (hyper-parameters) of the block parameters, based on general-user file access characteristics. In Section V, we extend our implementation discussion to APEX file system using the FUSE (FileSystem in UserSpace) framework [17]. In Section VI we provide a case study of overwriting video surveillance data using CryPy malware [18] and provide experimental results of the model and comparison with other works both for recovery and overheads to show that APEX outperforms them. Section VII concludes the paper and provides future directions to improve APEX.

II. RELATED WORK
The goal of data recovery is to recover lost data from a disk to maximum extent. This data might be 'lost' because the disk has been corrupted or the files have been deleted. We focus on the latter aspect of the problem that too from data stealing/deleting malware. There has been significant work on data recovery at different levels, including file system, file allocation software, and recovery tools. However, there still lacks a holistic system that focuses on this aspect on generic, highly recoverable data storage by modifying the allocation policy. Table I provides a brief summary for comparing APEX with other systems.
There are two main directions in which the work on data recovery has progressed. The first concerns how data is recovered after deletion, and the second concerns with allocating data such that recovery later is optimized. Significant parameters for comparison include overheads, on demand recover-ability, adaptivity to different application scenarios, and custom policy employ-ability among others. There has been work on dynamic file systems and allocation like by Ulrich et al. [19], where the data is allocated between different drives for optimum resource utilization and distribution. Complex parity generation and comparison methods are used, spanning multiple drives, for improved utilization and recovery performance. However, it lacks priority based allocation and replacement policies that are optimized for recovery and access time. The popular Andrew File System (AFS) [15] in distributed systems also provides a backup mechanism to recover deleted or lost files for a limited period of time. This is not suitable for Fog nodes due to limited disk space available (there is high storage-to-compute cost ratio in Fog framework deployment and other communication limitations across Fog network). Many efforts have also been made in the directions of hardware tweaking and optimizations. An example is by Hanson [20].
Techniques that involve tagging of file blocks with some identifiers have been used by Alhussein et al. in [22] and [24], where frameworks like FUSE have been used for development of forensic based file-systems. They provide forensic file identifiers at cluster-level file allocation to provide information needed for file types to be recovered after deletion. As they are only limited to file cluster identification and the identification of file types, the amount of recover-ability of data is limited because they completely ignore the file usage characteristics and temporal locality. Another adaptive approach by Stoica et al. [13] uses weighted least squares Iterative Adaptive Approach (IAA) to detect and recover missing data, but this works mostly across streams of data signals and is not scalable to actual file systems. We consider it because of its unique adaptive approach to categorize cluster cells for efficiently allocating them in buffers/disk. Other works like by Continella et al. [14] or Baek et al. [25] provide a selfhealing ransomware-aware filesystem which is capable of both detection and the recovery from ransomware attacks. It works by analyzing the I/O data trace of various processes and uses a classifier to detect if the process is maliciously deleting data. If such a process is discovered, it uses a recovery approach used by copy-on-write filesystems. This poses significant overheads in terms of disk space and I/O bandwidth requirements and hence is not optimum for Edge nodes. Another problem is that, it has non-zero detection error in file destructive ransomwares as it has been trained for those that are encryption based. We tested it for Gandcrab and it was not able to identify it.  [19] AFS [15] Hanson [20] Breeuwsma et al. [21] Alhussein et al [22] Stoica et al. [13] Huang et al. [23] Alhussein et al [24] Baek et al. [25] Lee et al. [26] Continella et al. [14] APEX [this work]  [23] has been proposed for recovering encrypted data from flash drives. They provide a ransomware tolerant SSD which has firmware-level recovery systems, but the main drawback of their approach is that they keep multiple copies of data and hence need significantly more space than required. Another disadvantage is that their approach is specific to SSDs and not for generic storage devices. Lee et al. [26] propose ExtSFR, a scalable file recovery framework for distributed filesystems in IoT domains. This uses files' metadata to identify and recover them, but ignore file usage and access characteristics which limit recoverability. In aforementioned works, file access characteristics, recovery based allocation strategies, and cluster identifiers are exploited from a narrow perspective and capabilities of adaptive priority based allocation approaches have not been fully leveraged. In addition, most systems overlook the constraints in edge paradigm and hence are not cost and/or energy efficient for such deployments. APEX ensures data security using adaptive prioritization of blocks in storage media based on recovery heuristics and provides efficient mechanisms that have minimal compute, bandwidth and space overheads.

III. RECOVERABILITY AWARE FILE ALLOCATION
In the previous section, we described the flaws of existing systems and emphasized on how a recovery-aware file allocation system can provide a more robust and efficient mechanism for recovering deleted data. Here we provide the details of implementing such system and later describe how much improvement in terms of recovery it provides. For this work, we have kept the threat model as a malicious entity which directly attacks the system to sabotage critical files while the attack surface is limited to the user application wherein the kernel is secured.

A. Block Parameters and Priority Factor
The four proposed parameters that act as heuristics to rank a block for its priority for allocation are History Factor (HF ), Usage Factor (U F ), Spatial Factor (SF ) and Linking Factor (LF ). The Priority Factor (P F ) of a block is a linear combination of these parameters. The weights of theses factors are kept as hyper-parameters which are dynamically learned for improved recovery based on the user's file usage characteristics in the APEX model. This priority score is used to sort the unused blocks in a priority queue which then is used for finding fresh blocks to allocate to a new file. Now, the Priority factor (P F ) is defined according to the equation: Priority Factor is periodically calculated for each unused block of the disk. Here the hyper-parameters: λ, σ, ρ, µ which are coefficients of the disk block parameters. They are dynamically updated based on the user's file access characteristics. The different types of clusters/blocks are Used and Unused. When a file is created, some unused blocks are allocated and thus belong to the Used category. When a file is deleted, the Used blocks that correspond to that file are converted to Unused category. The different types of files in APEX nomenclature are: • Used: File exists in disk • Deleted: File exists in disk but deleted and blocks can be overwritten (only partial fragments of the file may be present) • Obsolete: No block of the file exists in the current state of the disk Different types of operations are read, write, delete, create (new file). We now define the block parameters and reason their importance: 1) History factor (HF ): The history factor accounts for how old a particular file's blocks are, in terms of "delete" or "over-write" operations. Each time a file's blocks are deleted or over-written, the rest of the blocks' HF increases by one. At block level the history factor can be visualized as shown in Figure 1(a). Here, the "file" of the block shown as "a" represents the set of blocks that belong to the last file of which block "a" was part of. For different cases of a block, we have: • Unused: for every Delete/over-write operation, the HF is raised by 1 • Unused to used transition: set HF to 1 • Used: no change • Used to unused transition: set HF to 0 This parameter exists for each block in the disk. The reason HF is important for recovery is: if blocks of the same file are overwritten then the extent of recovery of other blocks decreases. This is also mentioned in other works [15], [25], [27] where they use similar notions to capture the history of file. When HF increases, it makes the recovery of the cluster more difficult and hence PF should increase, which implies that the positive scalar constant (λ) will be positive.
2) Usage Factor (U F ): The usage factor takes into account the usage of a file (and thus its blocks). It is quantified by the number of read/write operations on that particular file before deletion/over-writing. The higher the usage of a particular file, the more recovery sensitive (important to user) the file gets. The change to the usage factor based on the file operation is shown in Figure 1(b). The UF of all blocks in a disk are initialized to 0. For different cases of a blocks, we have: • Used: For each read/write operation of any blocks of the file, the UF of each file increases by 1 • Used to Unused transition: no change • Unused: no change • Unused to used transition: set UF to 1 when a new file is created Other works [25], [27] also use similar notions of file/block prioritization based on usage of file. This is because frequently used files are considered more important to the user. This means that the PF (priority for overwriting it) should reduce and hence the scalar constant (σ) has negative sign with it.
3) Spatial Factor (SF ): The spatial factor includes the possibility of the recovery of blocks located especially in the neighborhood of a particular block. Its importance has been shown in other works as well [25], [28] because of its direct effect on file access time. The spatial factor of a block is higher if the overall priority factor of the neighboring blocks are high. Thus, SF is kept as the average of blocks that are physically spatially adjacent. 'Spatial Adjacency' depends on the physical characteristics of the medium. For HDD we may consider the blocks in the same sector as the neighboring ones. As the blocks being allocated for a new file are the high priority blocks, if the neighboring blocks have high PF, the spatial locality would increase. Consequently, this block should also get replaced and hence for high SF, the PF should be high. This shows that the scalar constant (ρ) is positive. SFs of all blocks are updated after each I/O operation. For different cases for a block, we have: • Used: Reset to 0 • Unused: Average P F of nearby blocks This factor is initialized to 0. This would be very useful in HDDs, and our algorithm can take into account on the fly de-fragmentation in such storage devices. However, the introduction of SF should not hamper with the wear leveling algorithms employed by flash drives and thus this factor is

B. Functional Model Working
We use P F as a reasonable heuristic to rank blocks in the decreasing priority of being allocated to new files. Block allocation, whenever a new file is created, is thus based on the priority factor. The blocks with the highest priority factors are allocated to the new file, number equal to those required for the new file. Whenever a file is deleted, its used blocks are shifted to the unused blocks' set and this set is again used for allocation to new files with allocating those blocks first that have the highest PF.
We now show how the ranking based on priority factor can be improved further by tuning the hyperparameters: λ, σ, ρ, µ dynamically. This tuning is based on the file access characteristics of the user to allow more efficient allocation.
IV. HYPER-PARAMETER OPTIMIZATION: ADAPTIVE ALLOCATION MODEL In the previous section, we described how priority factor can be used to rank blocks to improve post-deletion data recovery. This heuristic measure is still an approximation and there exists scope for further tuning the hyperparameters: λ, σ, ρ, µ discussed before. This tuning can be dynamic based on user's file access characteristics which can make this heuristic more  precise and lead to better allocation. We next describe a simulated environment close to real life scenario to determine the optimum values of the hyperparameters.

A. Learning Model
We use Q-Learning, which is a reinforcement learning model to optimize the set of hyper-parameters. Here, the state of the Q-Learning Model is defined by the tuple of hyperparameters. An action is defined by the increment/decrement of the hyper parameters. Converging to the optimal set of these hyper parameters would be the goal of the model. The model is divided into two parts, the first is the learning model which optimizes these parameters. The other part is the allocation system, which allocates blocks to new files based on the current hyper-parameter set and corresponding P F s of the learning model.
Considering each I/O operation as one iteration, the learning model updates the coefficients at each iteration and gradually converges to the best set of values. The coefficients are updated frequently because of the dynamism of disk/file accesses. The model would be trained on the basis of a Performance measure (P ), which is a combination of the average recovery ratio of files and the spatial locality (only recovery ratio for random access drives). Each action would change this measure, and by the learning algorithm the model would converge to a optimum hyper-parameter set. In the building of the prototype File System APEX, we have trained the Q learning model based on some representative file access rates and distribution of common file types. Figure 2 shows a diagrammatic representation of the model and how the learning model interacts with the File Allocation Table (FAT), OS and the disk. As the state space needs to be finite and the model should be able to converge to a definite solution, the set of values on which the hyper-parameters vary is kept as: 1,2,..,10. This range is based on empirical results and convergence constraints. This gives a crude idea as to what are the values required for the best recovery efficiency keeping the least count of value measures to be 1.

B. Objective Function
The objective function, referred as performance P of the learning model is implemented as a linear combination of the weighted average Recovery Ratio (RR). RR is a standard metric for comparing recovery of file systems [14], [22] and is weighted by the usage frequency of the files. Moreover, a measure to quantify average access time of files in the disk [25], [28] is also common metric. We define for each file: • Recovery Ratio (RR): -For executable, objects and archived file types: 1 for complete recovery, 0 for partial/no recovery. Here, 0 ≤ α ≤ 1, 0 ≤ β ≤ 1 and α + β = 1. Both terms of which α and β are coefficients, are dependent on each other. The term involving access time depends not only on the spatial distribution of files but also the average size of current files which affects recovery of other files. It also affects recovery because in many spatial distributions the meta-data is erased which makes a partially recoverable file (i.e. some blocks of data exist) have RR = 0. The other term that involves recovery ratio depends on how many blocks of deleted files are present and also on which of them are present (meta-data or data). Different values of α and β are applicable to different scenarios. If we want to optimize recovery only, then α = 1 and β = 0, for example, where edge devices store critical data like video surveillance footage or health monitoring data. Such applications do not require high I/O bandwidth but critically require recoverability. If we want to optimize I/O only then α = 0 and β = 1. This case would arise in edge configurations with high bandwidth data streams and all data being stored in a separate database node or cloud which requires fast I/O.

C. Disk Simulator
The disk block size for simulation model is kept the same as the real value = 4KB. Total disk space is kept as 256MB and a file can vary from 16KB (4 blocks) to 1024KB/1MB (256 blocks). Based on the rules for parameter update, the parameter maps are created for each state, i.e, a hyper-parameter set. This simulator model also allocates the blocks (based on ranking on P F ) whenever there is a call from OS simulator (explained next). It also keeps track of the MRPF (Most Recent Parent File) for each block, which is a pair of the filename that a specific block belongs to (or did before logical deletion) and the set of blocks that were allocated to this particular file.

D. OS / File IO Simulator
This simulator does the file level/ OS level disk management. This introduces random file operations which belong to one of these categories: (1) Read/write, (2) Create file, (3) Delete file. The "Create file" operation updates the MRPF of each block that belongs to that new file after the operation.

E. Learning Hyper Parameters
Based on the definition of the hyper-parameters and performance function, the optimization problem is formulated as: maximize λ,σ,ρ,µ P subject to λ, σ, ρ, µ ∈ [1, 10]; λ, σ, ρ, µ ∈ N, Blocks allocated to new f iles in decreasing order of P F = λHF − σU F + ρSF + µLF As in general Q-Learning models, this learning model has an "Exploration factor" depicted as . This factor drops down from 1 exponentially. It decides with what probability a random action takes place. The probability with which a random action is chosen is and for an optimal action it is 1 − . As decreases, the model chooses the action with the highest ∆P , which is the change in the performance function of the learning model. Gradually, as the model explores, reduces and model converges to the optimal state. For this experiment, the learning model converges when is ≤ 3 × 10 −5 . For the simulation setting at this convergence point: MIN reaches 9.01 × 10 7 and OIN reaches 9.01 × 10 10 . The performance measure, as described earlier, starts from 44.00 (based on Ext4 prioritization factors). The value of P tends nearly 190 with time, thus based on the equation of performance, there is an approximately 280% improvement as shown in Figure 3. The hyper-parameter values converge to (4,7,1,9).
This set of hyper-parameter values are then used in a dynamic setting for block prioritization in the APEX framework. The initial Priority Factor, which is updated on-the-fly based on the learning model, used for the block allocation for new files in APEX is: To implement APEX, we used the FUSE framework [17]. FUSE (Filesystem in Userspace) is an interface for user programs to export a file-system to the Linux kernel. FUSE mainly consists of two components: the FUSE kernel module and the lib-fuse library. Libfuse provides the reference implementation for communicating with the FUSE kernel module. It is the most widely used library with active support that allows users to develop, simulate and test their own file-system without writing kernel-level code.
To implement APEX, we need the following structures: (1) Disk, (2) Directory, (3) File, (4) Block. For the Disk simulation system, we only required the Disk, File and Block structures while modifying them according to FUSE format and include a new Directory implementation for APEX. Instead of Disk being a 2D array of Blocks, now its a large ByteBuffer which is indexed by Blocks. Disk contains the optimal coefficient values of the parameters (found from the RL model), current and deleted file list a Heap of unused blocks and a HashSet of used blocks. The File and Directory are derived from an abstract class Path which has specifications required for a File system structure. Directory can have several children Paths (which can be a file or directory) recursively. File has several children Blocks, file-type (FUSE & linking factor).
At the block level, main operations are: 1) Allocate: Sets the block's state to used, initializes the block's parameters, updates the parent file pointer and obtains the linking factor (found by the parent file's FUSEFILEINFO).

VI. OVERWRITING VIDEO SURVEILLANCE USING CRYPY MALWARE: A CASE STUDY
In order to compare APEX with other works, we use a Fog environment built on FogBus [4] for video surveillance on Raspberry Pi based Fog Nodes. As such nodes are usually connected to cloud via the Internet, many viruses, trojans, etc. are likely to creep into the network. We compare APEX with other recovery specific systems that can be integrated in Edge nodes: AFS [15], FFS [22], ShieldFS [14], ExtSFR [26]. In order to compare the data recovery performance, similar tests were executed on the APEX File System and the Base (Ext4) File System, with other works and recovery ratios were compared. For a simple analysis, we keep the file system size for user data limited to 1GB. First, primary data was deleted using the CryPy malware [18] after custom modifications, and secondary data was written on the drive. After this, the primary data was recovered. We perform tests for both HDD and SSD, which give very similar results (difference of < 0.05 recovery ratio) and hence report the average. 1) Test files: Primary Data was kept consistent throughout the experiment to maintain consistency and consist of a set of 5 sample videos each of size = 95 MB. Secondary Data size was increased in each iteration by predefined constants and only written after soft deletion of primary data. Data recovered was measured in terms of the size of recovered primary data. Also measured in terms of recovered files that were view-able after recovery 2) Recovery ratio: Data recovered / P rimary Data size 3) Observations: Across different file systems as shown in Figure 4(a) and Figure 4(b), for the Secondary data size = 414 MB and 794 MB respectively, we see that the APEX file system has the highest recovery ratio. As there is no policy for recovery in Ext4, it has the least (even 0 MB in second case) recovery. As the surveillance footage was taken such that each video accounts for 1 hour of data, AFS file system with 1 hour of delayed deletion causes 4 out of 5 files to be permanently deleted. This remains unchanged in both experiments. For others including FFS, ShieldFS, and ExtSFR; as they use only file identifiers in blocks and not which files were most recently and frequently used (video files in our case), they overwrite their data and hence lead to lower recovery. APEX on the other hand allocates new files i.e. Secondary data to separate locations preventing overwriting of Original data, is able to recover maximum. APEX system improve the recovery ratio by 678%, and 32% compared to the base Ext4 and ExtSFR respectively for 414 MB secondary data and 31% compared to ExtSFR for 794 MB secondary data.

C. Experiment 2: Read-write performance
As the APEX file system adds the block level -prioritized file allocation implementation over Ext4, which leads to additional overhead, thus the FUSE implementation of APEX (c) Delete speed in MB/s Figure 5. Write, Read and Delete speed comparison was compared to the Base file system, which in our case is Ext4. To test the read, write and delete speed in both systems, we used FileBench Filesystem benchmarking tool [30]. These benchmarks provide read, write and delete speeds for n files, each of size m (where n and m are given as inputs to the benchmark code). For the current study, random files were sequentially created, read, written and deleted where n varied from 10 to 1000 and m varied from 1 MB to 1000 MB. Figures 5(a)-5(c) show the results in bytes per second for writing, reading and deleting for different frameworks using HDD media (which has higher overhead so we report these results). The graphs show that the delete operation speed for all frameworks except AFS is close to Ext4. Read/write speeds are lower than Ext4 but the overhead is minimum in APEX. This is primarily because of identifier mapping in blocks being updated periodically in FFS. In ShieldFS, the detection algorithm has its overhead which continuously monitors the disk footprint of filebench program and consumes bandwidth. Overall, APEX has the least overhead among all implementations.

D. Experiment 3: CPU and RAM overhead
Due to various complex background tasks of process I/O detection in ShieldFS, file block identification in FFS and backup of data in AFS, the CPU and RAM usage of such frameworks is much higher compared to APEX. ShieldFS uses many sophisticated cryptographic primitives to identify if a program could be 'potentially malicious'. This requires constant overhead of computation and memory. ExtSFR has a post-deletion inode tracing and journal checking protocol which needs to check the whole file system for very small changes. APEX maintains the state of the files, hence only the files of interest can be checked. FFS maintains 'forensic file system identifier' for each file and identifies the relevant information needed for recovery using such identifiers. These identifiers are stored in disk and are required to be fetched when checking for recoverable files in the file system, which makes it slow. APEX uses the disk cache information to update the block parameters of the most used blocks more frequently than others. This allows APEX to have a very small working set at any instant of time (maximum 7% in current tests). It integrates file allocation and energy management to maintain least CPU and memory consumption as shown in Figure 6. APEX can successfully simulate and provide optimum values of coefficients in the Priority Factor (PF) which can rank the blocks to optimize recovery performance. The model converges to give PF as given in Section IV. Using this factor (dynamically optimized by Q-Learning), if we rank all blocks in the disk then it can provide a file allocation system that has a higher data recovery ratio. Thus, at any point if we want to recover a file, it would be recovered to the maximum extent in this file system design compared to existing implementations. The current model gives a recovery performance improvement of 280%, where performance is determined as mentioned in Section IV. Experiments in Section VI-B show that the APEX improves the recovery ratio by 678%, and 32% compared to the base Ext4 file system and ExtSFR (best among the prior work). Hence, APEX can improve the data recovery with minimum read-write or compute overhead and hence is most apt for resource-constrained edge devices vulnerable to attacks using data stealing malware.
The proposed work only aims to enhance recover-ability of deleted files. This can be extended to secure file-systems from malicious transfer and corruption of files and to cover other types of file-systems like Distributed file-systems. Further, the model can optimize wear levelling in tandem with recovery performance, especially for Flash and SSDs. It can also be extended for emerging Non-Volatile Memories like RRAMs (Resistive Random Access Memory) [31], for upcoming energy efficient edge devices. The codes developed and used for data recovery and the Q-Learning Model with simulation results can be found at: https://github.com/HS-Optimization-with-AI.