inode->i_blocks - ea_blocks == 0);
}
-/*
- * Called at each iput().
- *
- * The inode may be "bad" if ext2_read_inode() saw an error from
- * ext2_get_inode(), so we need to check that to avoid freeing random disk
- * blocks.
- */
-void ext2_put_inode(struct inode *inode)
-{
- if (!is_bad_inode(inode))
- ext2_discard_prealloc(inode);
-}
-
static void ext2_truncate_nocheck (struct inode * inode);
/*
&ei->i_prealloc_count,
&ei->i_prealloc_block, err);
else
- result = ext2_new_block (inode, goal, 0, 0, err);
+ result = ext2_new_block(inode, goal, NULL, NULL, err);
}
#else
result = ext2_new_block (inode, goal, 0, 0, err);
}
typedef struct {
- u32 *p;
- u32 key;
+ __le32 *p;
+ __le32 key;
struct buffer_head *bh;
} Indirect;
-static inline void add_chain(Indirect *p, struct buffer_head *bh, u32 *v)
+static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
{
p->key = *(p->p = v);
p->bh = bh;
read_lock(&EXT2_I(inode)->i_meta_lock);
if (!verify_chain(chain, p))
goto changed;
- add_chain(++p, bh, (u32*)bh->b_data + *++offsets);
+ add_chain(++p, bh, (__le32*)bh->b_data + *++offsets);
read_unlock(&EXT2_I(inode)->i_meta_lock);
if (!p->key)
goto no_block;
static unsigned long ext2_find_near(struct inode *inode, Indirect *ind)
{
struct ext2_inode_info *ei = EXT2_I(inode);
- u32 *start = ind->bh ? (u32*) ind->bh->b_data : ei->i_data;
- u32 *p;
+ __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data;
+ __le32 *p;
unsigned long bg_start;
unsigned long colour;
{
struct ext2_inode_info *ei = EXT2_I(inode);
write_lock(&ei->i_meta_lock);
- if (block == ei->i_next_alloc_block + 1) {
+ if ((block == ei->i_next_alloc_block + 1) && ei->i_next_alloc_goal) {
ei->i_next_alloc_block++;
ei->i_next_alloc_goal++;
}
lock_buffer(bh);
memset(bh->b_data, 0, blocksize);
branch[n].bh = bh;
- branch[n].p = (u32*) bh->b_data + offsets[n];
+ branch[n].p = (__le32 *) bh->b_data + offsets[n];
*branch[n].p = branch[n].key;
set_buffer_uptodate(bh);
unlock_buffer(bh);
/* We are done with atomic stuff, now do the rest of housekeeping */
- inode->i_ctime = CURRENT_TIME;
+ inode->i_ctime = CURRENT_TIME_SEC;
/* had we spliced it onto indirect block? */
if (where->bh)
* reachable from inode.
*/
-static int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
+int ext2_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create)
{
int err = -EIO;
int offsets[4];
* or memcmp with zero_page, whatever is better for particular architecture.
* Linus?
*/
-static inline int all_zeroes(u32 *p, u32 *q)
+static inline int all_zeroes(__le32 *p, __le32 *q)
{
while (p < q)
if (*p++)
int depth,
int offsets[4],
Indirect chain[4],
- u32 *top)
+ __le32 *top)
{
Indirect *partial, *p;
int k, err;
write_unlock(&EXT2_I(inode)->i_meta_lock);
goto no_top;
}
- for (p=partial; p>chain && all_zeroes((u32*)p->bh->b_data,p->p); p--)
+ for (p=partial; p>chain && all_zeroes((__le32*)p->bh->b_data,p->p); p--)
;
/*
* OK, we've found the last block that must survive. The rest of our
* stored as little-endian 32-bit) and updating @inode->i_blocks
* appropriately.
*/
-static inline void ext2_free_data(struct inode *inode, u32 *p, u32 *q)
+static inline void ext2_free_data(struct inode *inode, __le32 *p, __le32 *q)
{
unsigned long block_to_free = 0, count = 0;
unsigned long nr;
* stored as little-endian 32-bit) and updating @inode->i_blocks
* appropriately.
*/
-static void ext2_free_branches(struct inode *inode, u32 *p, u32 *q, int depth)
+static void ext2_free_branches(struct inode *inode, __le32 *p, __le32 *q, int depth)
{
struct buffer_head * bh;
unsigned long nr;
continue;
}
ext2_free_branches(inode,
- (u32*)bh->b_data,
- (u32*)bh->b_data + addr_per_block,
+ (__le32*)bh->b_data,
+ (__le32*)bh->b_data + addr_per_block,
depth);
bforget(bh);
ext2_free_blocks(inode, nr, 1);
static void ext2_truncate_nocheck(struct inode * inode)
{
- u32 *i_data = EXT2_I(inode)->i_data;
+ __le32 *i_data = EXT2_I(inode)->i_data;
int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb);
int offsets[4];
Indirect chain[4];
Indirect *partial;
- int nr = 0;
+ __le32 nr = 0;
int n;
long iblock;
unsigned blocksize;
while (partial > chain) {
ext2_free_branches(inode,
partial->p + 1,
- (u32*)partial->bh->b_data + addr_per_block,
+ (__le32*)partial->bh->b_data+addr_per_block,
(chain+n-1) - partial);
mark_buffer_dirty_inode(partial->bh, inode);
brelse (partial->bh);
case EXT2_TIND_BLOCK:
;
}
- inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
if (inode_needs_sync(inode)) {
sync_mapping_buffers(inode->i_mapping);
ext2_sync_inode (inode);
{
unsigned int flags = EXT2_I(inode)->i_flags;
- inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
+ inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_IUNLINK|S_BARRIER|S_NOATIME|S_DIRSYNC);
if (flags & EXT2_SYNC_FL)
inode->i_flags |= S_SYNC;
if (flags & EXT2_APPEND_FL)
uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
}
- inode->i_uid = INOXID_UID(uid, gid);
- inode->i_gid = INOXID_GID(uid, gid);
- if (inode->i_sb->s_flags & MS_TAGXID)
- inode->i_xid = INOXID_XID(uid, gid, le16_to_cpu(raw_inode->i_raw_xid));
+ inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid);
+ inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid);
+ inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid,
+ le16_to_cpu(raw_inode->i_raw_xid));
inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
inode->i_size = le32_to_cpu(raw_inode->i_size);
struct ext2_inode_info *ei = EXT2_I(inode);
struct super_block *sb = inode->i_sb;
ino_t ino = inode->i_ino;
- uid_t uid = XIDINO_UID(inode->i_uid, inode->i_xid);
- gid_t gid = XIDINO_GID(inode->i_gid, inode->i_xid);
+ uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid);
+ gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid);
struct buffer_head * bh;
struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
int n;
raw_inode->i_uid_high = 0;
raw_inode->i_gid_high = 0;
}
-#ifdef CONFIG_INOXID_GID32
+#ifdef CONFIG_INOXID_INTERN
raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid);
#endif
raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
return err;
}
-void ext2_write_inode(struct inode *inode, int wait)
+int ext2_write_inode(struct inode *inode, int wait)
{
- ext2_update_inode(inode, wait);
+ return ext2_update_inode(inode, wait);
}
int ext2_sync_inode(struct inode *inode)
oldflags = EXT2_I(inode)->i_flags;
newflags = oldflags &
- ~(EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
+ ~(EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL | EXT2_BARRIER_FL);
if (flags & ATTR_FLAG_IMMUTABLE)
newflags |= EXT2_IMMUTABLE_FL;
if (flags & ATTR_FLAG_IUNLINK)
if (iattr->ia_valid & ATTR_ATTR_FLAG)
ext2_setattr_flags(inode, iattr->ia_attr_flags);
- inode_setattr(inode, iattr);
- if (iattr->ia_valid & ATTR_MODE)
+ error = inode_setattr(inode, iattr);
+ if (!error && (iattr->ia_valid & ATTR_MODE))
error = ext2_acl_chmod(inode);
return error;
}