mirror of
https://github.com/linux-apfs/linux-apfs-rw.git
synced 2026-08-18 02:19:59 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0667dbff17 | ||
|
|
af2ee526c0 | ||
|
|
44f4b4f631 | ||
|
|
b44d2a37bf | ||
|
|
4881d7c707 | ||
|
|
2982c8655f | ||
|
|
707d91b486 | ||
|
|
3e5c902a9a |
No files matched your search
@@ -217,6 +217,11 @@ struct apfs_ephemeral_object_info {
|
||||
/* Mount option flags for a container */
|
||||
#define APFS_CHECK_NODES 1
|
||||
#define APFS_READWRITE 2
|
||||
/*
|
||||
* Mount options for a container are decided on its first mount. This flag lets
|
||||
* future mounts know that has happened already.
|
||||
*/
|
||||
#define APFS_FLAGS_SET 4
|
||||
|
||||
/*
|
||||
* Container superblock data in memory
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
PACKAGE_NAME="linux-apfs-rw"
|
||||
PACKAGE_VERSION="0.3.10"
|
||||
PACKAGE_VERSION="0.3.11"
|
||||
|
||||
BUILT_MODULE_NAME[0]="apfs"
|
||||
DEST_MODULE_LOCATION[0]="/extra"
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
#include <linux/blk_types.h>
|
||||
#include "apfs.h"
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
|
||||
#define MAX(X, Y) ((X) <= (Y) ? (Y) : (X))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* apfs_ext_is_hole - Does this extent represent a hole in a sparse file?
|
||||
|
||||
+22
-11
@@ -285,10 +285,8 @@ static void apfs_trans_commit_work(struct work_struct *work)
|
||||
* (TODO).
|
||||
*/
|
||||
down_write(&nxi->nx_big_sem);
|
||||
mutex_lock(&nxs_mutex);
|
||||
if (!sb || sb->s_flags & SB_RDONLY) {
|
||||
/* The commit already took place, or there was an abort */
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
return;
|
||||
}
|
||||
@@ -330,11 +328,9 @@ int apfs_transaction_start(struct super_block *sb, struct apfs_max_ops maxops)
|
||||
int err;
|
||||
|
||||
down_write(&nxi->nx_big_sem);
|
||||
mutex_lock(&nxs_mutex); /* Don't mount during a transaction */
|
||||
|
||||
if (sb->s_flags & SB_RDONLY) {
|
||||
/* A previous transaction has failed; this should be rare */
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
return -EROFS;
|
||||
}
|
||||
@@ -346,7 +342,6 @@ int apfs_transaction_start(struct super_block *sb, struct apfs_max_ops maxops)
|
||||
if (!nxi->nx_eph_list) {
|
||||
err = apfs_read_ephemeral_objects(sb);
|
||||
if (err) {
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
apfs_err(sb, "failed to read the ephemeral objects");
|
||||
return err;
|
||||
@@ -440,14 +435,12 @@ int apfs_transaction_flush_all_inodes(struct super_block *sb)
|
||||
list_del_init(&ai->i_list);
|
||||
|
||||
nx_trans->t_state |= APFS_NX_TRANS_COMMITTING;
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
|
||||
/* Unlocked, so it may call evict() and wait for writeback */
|
||||
iput(inode);
|
||||
|
||||
down_write(&nxi->nx_big_sem);
|
||||
mutex_lock(&nxs_mutex);
|
||||
nx_trans->t_state = 0;
|
||||
|
||||
/* Transaction aborted during writeback, error code is lost */
|
||||
@@ -682,7 +675,11 @@ static int apfs_transaction_commit_nx(struct super_block *sb)
|
||||
}
|
||||
list_for_each_entry_safe(bhi, tmp, &nx_trans->t_buffers, list) {
|
||||
struct buffer_head *bh = bhi->bh;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
|
||||
struct folio *folio = NULL;
|
||||
#else
|
||||
struct page *page = NULL;
|
||||
#endif
|
||||
bool is_metadata;
|
||||
|
||||
ASSERT(buffer_trans(bh));
|
||||
@@ -702,27 +699,44 @@ static int apfs_transaction_commit_nx(struct super_block *sb)
|
||||
kfree(bhi);
|
||||
bhi = NULL;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
|
||||
folio = page_folio(bh->b_page);
|
||||
folio_get(folio);
|
||||
#else
|
||||
page = bh->b_page;
|
||||
get_page(page);
|
||||
#endif
|
||||
|
||||
is_metadata = buffer_csum(bh);
|
||||
clear_buffer_csum(bh);
|
||||
put_bh(bh);
|
||||
bh = NULL;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
|
||||
folio_lock(folio);
|
||||
folio_mkclean(folio);
|
||||
#else
|
||||
/* Future writes to mmapped areas should fault for CoW */
|
||||
lock_page(page);
|
||||
page_mkclean(page);
|
||||
#endif
|
||||
/* XXX: otherwise, the page cache fills up and crashes the machine */
|
||||
if (!is_metadata) {
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
|
||||
try_to_free_buffers(folio);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
|
||||
try_to_free_buffers(page_folio(page));
|
||||
#else
|
||||
try_to_free_buffers(page);
|
||||
#endif
|
||||
}
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
|
||||
folio_unlock(folio);
|
||||
folio_put(folio);
|
||||
#else
|
||||
unlock_page(page);
|
||||
put_page(page);
|
||||
#endif
|
||||
}
|
||||
err = apfs_checkpoint_end(sb);
|
||||
if (err) {
|
||||
@@ -834,7 +848,6 @@ int apfs_transaction_commit(struct super_block *sb)
|
||||
mod_delayed_work(system_wq, &trans->t_work, msecs_to_jiffies(100));
|
||||
}
|
||||
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
return 0;
|
||||
}
|
||||
@@ -928,7 +941,6 @@ void apfs_transaction_abort(struct super_block *sb)
|
||||
/* Transaction already aborted, do nothing */
|
||||
ASSERT(list_empty(&nx_trans->t_inodes));
|
||||
ASSERT(list_empty(&nx_trans->t_buffers));
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
return;
|
||||
}
|
||||
@@ -966,7 +978,6 @@ void apfs_transaction_abort(struct super_block *sb)
|
||||
*/
|
||||
apfs_force_readonly(nxi);
|
||||
|
||||
mutex_unlock(&nxs_mutex);
|
||||
up_write(&nxi->nx_big_sem);
|
||||
|
||||
list_for_each_entry_safe(ai, ai_tmp, &nx_trans->t_inodes, i_list) {
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/nls.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/version.h>
|
||||
#include "unicode.h"
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
|
||||
#define MIN(X, Y) ((X) <= (Y) ? (X) : (Y))
|
||||
#endif
|
||||
|
||||
/* The arrays of unicode data are defined at the bottom of the file */
|
||||
/* TODO: would a single trie with all the data be more efficient? */
|
||||
|
||||
Reference in new issue
Block a user