From: Roman Zippel <zippel@linux-m68k.org>
To: Andrew Morton <akpm@osdl.org>, linux-fsdevel@vger.kernel.org
Subject: [PATCH 5/6] write back resource info directly
Date: Thu, 21 Oct 2004 01:13:58 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.61.0410210113490.1083@scrub.home> (raw)
Write back the information for a dirty resource inode directly and not
via the main inode, as at the time the latter is written the former
might already be gone.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Index: linux-2.6-hfs/fs/hfs/inode.c
===================================================================
--- linux-2.6-hfs.orig/fs/hfs/inode.c 2004-10-21 00:43:13.381901456 +0200
+++ linux-2.6-hfs/fs/hfs/inode.c 2004-10-21 00:45:39.387825161 +0200
@@ -386,6 +386,7 @@ void hfs_inode_write_fork(struct inode *
int hfs_write_inode(struct inode *inode, int unused)
{
+ struct inode *main_inode = inode;
struct hfs_find_data fd;
hfs_cat_rec rec;
@@ -408,24 +409,22 @@ int hfs_write_inode(struct inode *inode,
}
}
- if (HFS_IS_RSRC(inode)) {
- mark_inode_dirty(HFS_I(inode)->rsrc_inode);
- return 0;
- }
+ if (HFS_IS_RSRC(inode))
+ main_inode = HFS_I(inode)->rsrc_inode;
- if (!inode->i_nlink)
+ if (!main_inode->i_nlink)
return 0;
- if (hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd))
+ if (hfs_find_init(HFS_SB(main_inode->i_sb)->cat_tree, &fd))
/* panic? */
return -EIO;
- fd.search_key->cat = HFS_I(inode)->cat_key;
+ fd.search_key->cat = HFS_I(main_inode)->cat_key;
if (hfs_brec_find(&fd))
/* panic? */
goto out;
- if (S_ISDIR(inode->i_mode)) {
+ if (S_ISDIR(main_inode->i_mode)) {
if (fd.entrylength < sizeof(struct hfs_cat_dir))
/* panic? */;
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
@@ -439,6 +438,13 @@ int hfs_write_inode(struct inode *inode,
hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
sizeof(struct hfs_cat_dir));
+ } else if (HFS_IS_RSRC(inode)) {
+ hfs_bnode_read(fd.bnode, &rec, fd.entryoffset,
+ sizeof(struct hfs_cat_file));
+ hfs_inode_write_fork(inode, rec.file.RExtRec,
+ &rec.file.RLgLen, &rec.file.RPyLen);
+ hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
+ sizeof(struct hfs_cat_file));
} else {
if (fd.entrylength < sizeof(struct hfs_cat_file))
/* panic? */;
@@ -453,9 +459,6 @@ int hfs_write_inode(struct inode *inode,
else
rec.file.Flags |= HFS_FIL_LOCK;
hfs_inode_write_fork(inode, rec.file.ExtRec, &rec.file.LgLen, &rec.file.PyLen);
- if (HFS_I(inode)->rsrc_inode)
- hfs_inode_write_fork(HFS_I(inode)->rsrc_inode, rec.file.RExtRec,
- &rec.file.RLgLen, &rec.file.RPyLen);
rec.file.MdDat = hfs_u_to_mtime(inode->i_mtime);
hfs_bnode_write(fd.bnode, &rec, fd.entryoffset,
Index: linux-2.6-hfs/fs/hfsplus/inode.c
===================================================================
--- linux-2.6-hfs.orig/fs/hfsplus/inode.c 2004-10-21 00:43:06.411098703 +0200
+++ linux-2.6-hfs/fs/hfsplus/inode.c 2004-10-21 00:46:55.995668252 +0200
@@ -489,26 +489,25 @@ int hfsplus_cat_read_inode(struct inode
int hfsplus_cat_write_inode(struct inode *inode)
{
+ struct inode *main_inode = inode;
struct hfs_find_data fd;
hfsplus_cat_entry entry;
- if (HFSPLUS_IS_RSRC(inode)) {
- mark_inode_dirty(HFSPLUS_I(inode).rsrc_inode);
- return 0;
- }
+ if (HFSPLUS_IS_RSRC(inode))
+ main_inode = HFSPLUS_I(inode).rsrc_inode;
- if (!inode->i_nlink)
+ if (!main_inode->i_nlink)
return 0;
- if (hfs_find_init(HFSPLUS_SB(inode->i_sb).cat_tree, &fd))
+ if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb).cat_tree, &fd))
/* panic? */
return -EIO;
- if (hfsplus_find_cat(inode->i_sb, inode->i_ino, &fd))
+ if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
/* panic? */
goto out;
- if (S_ISDIR(inode->i_mode)) {
+ if (S_ISDIR(main_inode->i_mode)) {
struct hfsplus_cat_folder *folder = &entry.folder;
if (fd.entrylength < sizeof(struct hfsplus_cat_folder))
@@ -523,6 +522,13 @@ int hfsplus_cat_write_inode(struct inode
folder->valence = cpu_to_be32(inode->i_size - 2);
hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_folder));
+ } else if (HFSPLUS_IS_RSRC(inode)) {
+ struct hfsplus_cat_file *file = &entry.file;
+ hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
+ sizeof(struct hfsplus_cat_file));
+ hfsplus_inode_write_fork(inode, &file->rsrc_fork);
+ hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
+ sizeof(struct hfsplus_cat_file));
} else {
struct hfsplus_cat_file *file = &entry.file;
@@ -531,8 +537,6 @@ int hfsplus_cat_write_inode(struct inode
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
sizeof(struct hfsplus_cat_file));
hfsplus_inode_write_fork(inode, &file->data_fork);
- if (HFSPLUS_I(inode).rsrc_inode)
- hfsplus_inode_write_fork(HFSPLUS_I(inode).rsrc_inode, &file->rsrc_fork);
if (S_ISREG(inode->i_mode))
HFSPLUS_I(inode).dev = inode->i_nlink;
if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
reply other threads:[~2004-10-20 23:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.61.0410210113490.1083@scrub.home \
--to=zippel@linux-m68k.org \
--cc=akpm@osdl.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).