Skip to content

Commit

Permalink
Revert "ANDROID: Incremental fs: Create mapped file"
Browse files Browse the repository at this point in the history
This reverts commit 0eae0d2.

Set incfs back to rvc shipping incfs

Bug: 178509184
Test: incfs_test passes
Signed-off-by: Paul Lawrence <[email protected]>
Change-Id: Ic8e2c2b8b0bcbc2df620cb7a3ded3d0df93f3f29
  • Loading branch information
PaulLawrenceGoogle committed Jan 26, 2021
1 parent a7538ee commit 6fe44a5
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 571 deletions.
88 changes: 0 additions & 88 deletions fs/incfs/data_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <linux/ktime.h>
#include <linux/lz4.h>
#include <linux/mm.h>
#include <linux/namei.h>
#include <linux/pagemap.h>
#include <linux/slab.h>
#include <linux/types.h>
Expand Down Expand Up @@ -124,86 +123,6 @@ static void data_file_segment_init(struct data_file_segment *segment)
INIT_LIST_HEAD(&segment->reads_list_head);
}

char *file_id_to_str(incfs_uuid_t id)
{
char *result = kmalloc(1 + sizeof(id.bytes) * 2, GFP_NOFS);
char *end;

if (!result)
return NULL;

end = bin2hex(result, id.bytes, sizeof(id.bytes));
*end = 0;
return result;
}

struct dentry *incfs_lookup_dentry(struct dentry *parent, const char *name)
{
struct inode *inode;
struct dentry *result = NULL;

if (!parent)
return ERR_PTR(-EFAULT);

inode = d_inode(parent);
inode_lock_nested(inode, I_MUTEX_PARENT);
result = lookup_one_len(name, parent, strlen(name));
inode_unlock(inode);

if (IS_ERR(result))
pr_warn("%s err:%ld\n", __func__, PTR_ERR(result));

return result;
}

static struct data_file *handle_mapped_file(struct mount_info *mi,
struct data_file *df)
{
char *file_id_str;
struct dentry *index_file_dentry;
struct path path;
struct file *bf;
struct data_file *result = NULL;

file_id_str = file_id_to_str(df->df_id);
if (!file_id_str)
return ERR_PTR(-ENOENT);

index_file_dentry = incfs_lookup_dentry(mi->mi_index_dir,
file_id_str);
kfree(file_id_str);
if (!index_file_dentry)
return ERR_PTR(-ENOENT);
if (IS_ERR(index_file_dentry))
return (struct data_file *)index_file_dentry;
if (!d_really_is_positive(index_file_dentry)) {
result = ERR_PTR(-ENOENT);
goto out;
}

path = (struct path) {
.mnt = mi->mi_backing_dir_path.mnt,
.dentry = index_file_dentry
};

bf = dentry_open(&path, O_RDWR | O_NOATIME | O_LARGEFILE, mi->mi_owner);
if (IS_ERR(bf)) {
result = (struct data_file *)bf;
goto out;
}

result = incfs_open_data_file(mi, bf);
fput(bf);
if (IS_ERR(result))
goto out;

result->df_mapped_offset = df->df_metadata_off;

out:
dput(index_file_dentry);
return result;
}

struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf)
{
struct data_file *df = NULL;
Expand Down Expand Up @@ -248,13 +167,6 @@ struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf)
if (size > 0)
df->df_data_block_count = get_blocks_count_for_size(size);

if (df->df_header_flags & INCFS_FILE_MAPPED) {
struct data_file *mapped_df = handle_mapped_file(mi, df);

incfs_free_data_file(df);
return mapped_df;
}

md_records = incfs_scan_metadata_chain(df);
if (md_records < 0)
error = md_records;
Expand Down
5 changes: 0 additions & 5 deletions fs/incfs/data_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ struct data_file {
/* Total number of blocks, data + hash */
int df_total_block_count;

/* For mapped files, the offset into the actual file */
loff_t df_mapped_offset;

struct file_attr n_attr;

struct mtree *df_hash_tree;
Expand Down Expand Up @@ -274,8 +271,6 @@ int incfs_realloc_mount_info(struct mount_info *mi,

void incfs_free_mount_info(struct mount_info *mi);

char *file_id_to_str(incfs_uuid_t id);
struct dentry *incfs_lookup_dentry(struct dentry *parent, const char *name);
struct data_file *incfs_open_data_file(struct mount_info *mi, struct file *bf);
void incfs_free_data_file(struct data_file *df);

Expand Down
39 changes: 4 additions & 35 deletions fs/incfs/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ int incfs_write_file_header_flags(struct backing_file_context *bfc, u32 flags)
return -EFAULT;

return write_to_bf(bfc, &flags, sizeof(flags),
offsetof(struct incfs_file_header, fh_flags));
offsetof(struct incfs_file_header,
fh_file_header_flags));
}

/*
Expand Down Expand Up @@ -384,7 +385,7 @@ int incfs_write_signature_to_backing_file(struct backing_file_context *bfc,
/*
* Write a backing file header
* It should always be called only on empty file.
* fh.fh_first_md_offset is 0 for now, but will be updated
* incfs_super_block.s_first_md_offset is 0 for now, but will be updated
* once first metadata record is added.
*/
int incfs_write_fh_to_backing_file(struct backing_file_context *bfc,
Expand Down Expand Up @@ -414,38 +415,6 @@ int incfs_write_fh_to_backing_file(struct backing_file_context *bfc,
return write_to_bf(bfc, &fh, sizeof(fh), file_pos);
}

/*
* Write a backing file header for a mapping file
* It should always be called only on empty file.
*/
int incfs_write_mapping_fh_to_backing_file(struct backing_file_context *bfc,
incfs_uuid_t *uuid, u64 file_size, u64 offset)
{
struct incfs_file_header fh = {};
loff_t file_pos = 0;

if (!bfc)
return -EFAULT;

fh.fh_magic = cpu_to_le64(INCFS_MAGIC_NUMBER);
fh.fh_version = cpu_to_le64(INCFS_FORMAT_CURRENT_VER);
fh.fh_header_size = cpu_to_le16(sizeof(fh));
fh.fh_original_offset = cpu_to_le64(offset);
fh.fh_data_block_size = cpu_to_le16(INCFS_DATA_FILE_BLOCK_SIZE);

fh.fh_mapped_file_size = cpu_to_le64(file_size);
fh.fh_original_uuid = *uuid;
fh.fh_flags = INCFS_FILE_MAPPED;

LOCK_REQUIRED(bfc->bc_mutex);

file_pos = incfs_get_end_offset(bfc->bc_file);
if (file_pos != 0)
return -EEXIST;

return write_to_bf(bfc, &fh, sizeof(fh), file_pos);
}

/* Write a given data block and update file's blockmap to point it. */
int incfs_write_data_block_to_backing_file(struct backing_file_context *bfc,
struct mem_range block, int block_index,
Expand Down Expand Up @@ -629,7 +598,7 @@ int incfs_read_file_header(struct backing_file_context *bfc,
if (file_size)
*file_size = le64_to_cpu(fh.fh_file_size);
if (flags)
*flags = le32_to_cpu(fh.fh_flags);
*flags = le32_to_cpu(fh.fh_file_header_flags);
return 0;
}

Expand Down
45 changes: 14 additions & 31 deletions fs/incfs/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
*
*
* +-------------------------------------------+
* | incfs_file_header |]---+
* | incfs_super_block |]---+
* +-------------------------------------------+ |
* | metadata |<---+
* | incfs_file_signature |]---+
Expand Down Expand Up @@ -123,7 +123,6 @@ enum incfs_metadata_type {

enum incfs_file_header_flags {
INCFS_FILE_COMPLETE = 1 << 0,
INCFS_FILE_MAPPED = 1 << 1,
};

/* Header included at the beginning of all metadata records on the disk. */
Expand Down Expand Up @@ -165,33 +164,20 @@ struct incfs_file_header {
__le16 fh_data_block_size;

/* File flags, from incfs_file_header_flags */
__le32 fh_flags;
__le32 fh_file_header_flags;

union {
/* Standard incfs file */
struct {
/* Offset of the first metadata record */
__le64 fh_first_md_offset;

/* Full size of the file's content */
__le64 fh_file_size;

/* File uuid */
incfs_uuid_t fh_uuid;
};

/* Mapped file - INCFS_FILE_MAPPED set in fh_flags */
struct {
/* Offset in original file */
__le64 fh_original_offset;

/* Full size of the file's content */
__le64 fh_mapped_file_size;

/* Original file's uuid */
incfs_uuid_t fh_original_uuid;
};
};
/* Offset of the first metadata record */
__le64 fh_first_md_offset;

/*
* Put file specific information after this point
*/

/* Full size of the file's content */
__le64 fh_file_size;

/* File uuid */
incfs_uuid_t fh_uuid;
} __packed;

enum incfs_block_map_entry_flags {
Expand Down Expand Up @@ -308,9 +294,6 @@ int incfs_write_blockmap_to_backing_file(struct backing_file_context *bfc,
int incfs_write_fh_to_backing_file(struct backing_file_context *bfc,
incfs_uuid_t *uuid, u64 file_size);

int incfs_write_mapping_fh_to_backing_file(struct backing_file_context *bfc,
incfs_uuid_t *uuid, u64 file_size, u64 offset);

int incfs_write_data_block_to_backing_file(struct backing_file_context *bfc,
struct mem_range block,
int block_index, loff_t bm_base_off,
Expand Down
Loading

0 comments on commit 6fe44a5

Please sign in to comment.