Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / reiserfs / inode.c
index 95051d44a918e141ac45bccd79ff315997dfefc1..57917932212eb33d68a0f626766c79fb608c442a 100644 (file)
@@ -199,7 +199,7 @@ static inline void set_block_dev_mapped(struct buffer_head *bh,
 // files which were created in the earlier version can not be longer,
 // than 2 gb
 //
-static int file_capable(struct inode *inode, long block)
+static int file_capable(struct inode *inode, sector_t block)
 {
        if (get_inode_item_key_version(inode) != KEY_FORMAT_3_5 ||      // it is new file.
            block < (1 << (31 - inode->i_sb->s_blocksize_bits)))        // old file, but 'block' is inside of 2gb
@@ -208,8 +208,8 @@ static int file_capable(struct inode *inode, long block)
        return 0;
 }
 
-/*static*/ int restart_transaction(struct reiserfs_transaction_handle *th,
-                                  struct inode *inode, struct treepath *path)
+static int restart_transaction(struct reiserfs_transaction_handle *th,
+                              struct inode *inode, struct treepath *path)
 {
        struct super_block *s = th->t_super;
        int len = th->t_blocks_allocated;
@@ -242,7 +242,7 @@ static int file_capable(struct inode *inode, long block)
 // Please improve the english/clarity in the comment above, as it is
 // hard to understand.
 
-static int _get_block_create_0(struct inode *inode, long block,
+static int _get_block_create_0(struct inode *inode, sector_t block,
                               struct buffer_head *bh_result, int args)
 {
        INITIALIZE_PATH(path);
@@ -250,7 +250,7 @@ static int _get_block_create_0(struct inode *inode, long block,
        struct buffer_head *bh;
        struct item_head *ih, tmp_ih;
        int fs_gen;
-       int blocknr;
+       b_blocknr_t blocknr;
        char *p = NULL;
        int chars;
        int ret;
@@ -569,7 +569,7 @@ static int convert_tail_for_hole(struct inode *inode,
 }
 
 static inline int _allocate_block(struct reiserfs_transaction_handle *th,
-                                 long block,
+                                 sector_t block,
                                  struct inode *inode,
                                  b_blocknr_t * allocated_block_nr,
                                  struct treepath *path, int flags)
@@ -1515,19 +1515,20 @@ struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key)
        return inode;
 }
 
-struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp)
+static struct dentry *reiserfs_get_dentry(struct super_block *sb,
+       u32 objectid, u32 dir_id, u32 generation)
+
 {
-       __u32 *data = vobjp;
        struct cpu_key key;
        struct dentry *result;
        struct inode *inode;
 
-       key.on_disk_key.k_objectid = data[0];
-       key.on_disk_key.k_dir_id = data[1];
+       key.on_disk_key.k_objectid = objectid;
+       key.on_disk_key.k_dir_id = dir_id;
        reiserfs_write_lock(sb);
        inode = reiserfs_iget(sb, &key);
-       if (inode && !IS_ERR(inode) && data[2] != 0 &&
-           data[2] != inode->i_generation) {
+       if (inode && !IS_ERR(inode) && generation != 0 &&
+           generation != inode->i_generation) {
                iput(inode);
                inode = NULL;
        }
@@ -1535,7 +1536,7 @@ struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp)
        if (!inode)
                inode = ERR_PTR(-ESTALE);
        if (IS_ERR(inode))
-               return ERR_PTR(PTR_ERR(inode));
+               return ERR_CAST(inode);
        result = d_alloc_anon(inode);
        if (!result) {
                iput(inode);
@@ -1544,14 +1545,9 @@ struct dentry *reiserfs_get_dentry(struct super_block *sb, void *vobjp)
        return result;
 }
 
-struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
-                                 int len, int fhtype,
-                                 int (*acceptable) (void *contect,
-                                                    struct dentry * de),
-                                 void *context)
+struct dentry *reiserfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
+               int fh_len, int fh_type)
 {
-       __u32 obj[3], parent[3];
-
        /* fhtype happens to reflect the number of u32s encoded.
         * due to a bug in earlier code, fhtype might indicate there
         * are more u32s then actually fitted.
@@ -1564,32 +1560,28 @@ struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 * data,
         *   6 - as above plus generation of directory
         * 6 does not fit in NFSv2 handles
         */
-       if (fhtype > len) {
-               if (fhtype != 6 || len != 5)
+       if (fh_type > fh_len) {
+               if (fh_type != 6 || fh_len != 5)
                        reiserfs_warning(sb,
-                                        "nfsd/reiserfs, fhtype=%d, len=%d - odd",
-                                        fhtype, len);
-               fhtype = 5;
+                               "nfsd/reiserfs, fhtype=%d, len=%d - odd",
+                               fh_type, fh_len);
+               fh_type = 5;
        }
 
-       obj[0] = data[0];
-       obj[1] = data[1];
-       if (fhtype == 3 || fhtype >= 5)
-               obj[2] = data[2];
-       else
-               obj[2] = 0;     /* generation number */
+       return reiserfs_get_dentry(sb, fid->raw[0], fid->raw[1],
+               (fh_type == 3 || fh_type >= 5) ? fid->raw[2] : 0);
+}
 
-       if (fhtype >= 4) {
-               parent[0] = data[fhtype >= 5 ? 3 : 2];
-               parent[1] = data[fhtype >= 5 ? 4 : 3];
-               if (fhtype == 6)
-                       parent[2] = data[5];
-               else
-                       parent[2] = 0;
-       }
-       return sb->s_export_op->find_exported_dentry(sb, obj,
-                                                    fhtype < 4 ? NULL : parent,
-                                                    acceptable, context);
+struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid,
+               int fh_len, int fh_type)
+{
+       if (fh_type < 4)
+               return NULL;
+
+       return reiserfs_get_dentry(sb,
+               (fh_type >= 5) ? fid->raw[3] : fid->raw[2],
+               (fh_type >= 5) ? fid->raw[4] : fid->raw[3],
+               (fh_type == 6) ? fid->raw[5] : 0);
 }
 
 int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp,
@@ -2151,7 +2143,7 @@ int reiserfs_truncate_file(struct inode *p_s_inode, int update_timestamps)
                /* if we are not on a block boundary */
                if (length) {
                        length = blocksize - length;
-                       zero_user_page(page, offset, length, KM_USER0);
+                       zero_user(page, offset, length);
                        if (buffer_mapped(bh) && bh->b_blocknr != 0) {
                                mark_buffer_dirty(bh);
                        }
@@ -2375,7 +2367,7 @@ static int reiserfs_write_full_page(struct page *page,
                        unlock_page(page);
                        return 0;
                }
-               zero_user_page(page, last_offset, PAGE_CACHE_SIZE - last_offset, KM_USER0);
+               zero_user_segment(page, last_offset, PAGE_CACHE_SIZE);
        }
        bh = head;
        block = page->index << (PAGE_CACHE_SHIFT - s->s_blocksize_bits);
@@ -3061,7 +3053,11 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
        struct inode *inode = dentry->d_inode;
        int error;
-       unsigned int ia_valid = attr->ia_valid;
+       unsigned int ia_valid;
+
+       /* must be turned off for recursive notify_change calls */
+       ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
+
        reiserfs_write_lock(inode->i_sb);
        if (attr->ia_valid & ATTR_SIZE) {
                /* version 2 items will be caught by the s_maxbytes check