#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/slab.h>
+#include <linux/migrate.h>
static int read_block(struct inode *inode, void *addr, unsigned int block,
struct ubifs_data_node *dn)
goto dump;
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
+
+ if (UBIFS_COMPR_LZ4K == le16_to_cpu(dn->compr_type))
+ out_len = len; //Jack modify for lz4k decompress
+ else
out_len = UBIFS_BLOCK_SIZE;
err = ubifs_decompress(&dn->data, dlen, addr, &out_len,
le16_to_cpu(dn->compr_type));
goto out_err;
dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
+
+ if (UBIFS_COMPR_LZ4K == le16_to_cpu(dn->compr_type))
+ out_len = len; //Jack modify for lz4k decompress
+ else
out_len = UBIFS_BLOCK_SIZE;
err = ubifs_decompress(&dn->data, dlen, addr, &out_len,
le16_to_cpu(dn->compr_type));
return ret;
}
+#ifdef CONFIG_MIGRATION
+static int ubifs_migrate_page(struct address_space *mapping,
+ struct page *newpage, struct page *page, enum migrate_mode mode)
+{
+ int rc;
+
+ rc = migrate_page_move_mapping(mapping, newpage, page, NULL, mode);
+ if (rc != MIGRATEPAGE_SUCCESS)
+ return rc;
+
+ if (PagePrivate(page)) {
+ ClearPagePrivate(page);
+ SetPagePrivate(newpage);
+ }
+
+ migrate_page_copy(newpage, page);
+ return MIGRATEPAGE_SUCCESS;
+}
+#endif
+
static int ubifs_releasepage(struct page *page, gfp_t unused_gfp_flags)
{
/*
}
wait_for_stable_page(page);
- unlock_page(page);
- return 0;
+ return VM_FAULT_LOCKED;
out_unlock:
unlock_page(page);
return 0;
}
+//MTK add for cts
+long ubifs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
+{
+ int err;
+ struct inode *inode = file->f_mapping->host;
+ struct ubifs_info *c = inode->i_sb->s_fs_info;
+ struct iattr newattrs;
+
+ loff_t new_len = offset + len;
+ if (len < 0 || offset < 0)
+ return -EINVAL;
+
+ if(new_len < inode->i_size)
+ return -EINVAL;
+
+ newattrs.ia_size = new_len;
+ newattrs.ia_valid = ATTR_SIZE | ATTR_MTIME|ATTR_CTIME;
+ newattrs.ia_file = file;
+ newattrs.ia_valid |= ATTR_FILE;
+
+
+ err = do_setattr(c, inode, &newattrs);
+ return err;
+}
+
const struct address_space_operations ubifs_file_address_operations = {
.readpage = ubifs_readpage,
.writepage = ubifs_writepage,
.write_end = ubifs_write_end,
.invalidatepage = ubifs_invalidatepage,
.set_page_dirty = ubifs_set_page_dirty,
+#ifdef CONFIG_MIGRATION
+ .migratepage = ubifs_migrate_page,
+#endif
.releasepage = ubifs_releasepage,
};
.follow_link = ubifs_follow_link,
.setattr = ubifs_setattr,
.getattr = ubifs_getattr,
+ .setxattr = ubifs_setxattr,
+ .getxattr = ubifs_getxattr,
+ .listxattr = ubifs_listxattr,
+ .removexattr = ubifs_removexattr,
};
const struct file_operations ubifs_file_operations = {
#ifdef CONFIG_COMPAT
.compat_ioctl = ubifs_compat_ioctl,
#endif
+ .fallocate = ubifs_fallocate,
};