Merge tag 'v3.10.103' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / fs / ext4 / inode.c
index d4d72659803cab82b21ec6a1dd15b584fad0c8ea..5ee08a717fee20b551060917e4aced49a51a4ef6 100644 (file)
@@ -46,6 +46,7 @@
 #include "truncate.h"
 
 #include <trace/events/ext4.h>
+#include <linux/blkdev.h>
 
 #define MPAGE_DA_EXTENT_TAIL 0x01
 
@@ -206,9 +207,9 @@ void ext4_evict_inode(struct inode *inode)
                 * Note that directories do not have this problem because they
                 * don't use page cache.
                 */
-               if (ext4_should_journal_data(inode) &&
-                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) &&
-                   inode->i_ino != EXT4_JOURNAL_INO) {
+               if (inode->i_ino != EXT4_JOURNAL_INO &&
+                   ext4_should_journal_data(inode) &&
+                   (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) {
                        journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
                        tid_t commit_tid = EXT4_I(inode)->i_datasync_tid;
 
@@ -984,6 +985,13 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
        struct page *page;
        pgoff_t index;
        unsigned from, to;
+#if defined(FEATURE_STORAGE_PID_LOGGER)
+               extern unsigned char *page_logger;
+               struct page_pid_logger *tmp_logger;
+               unsigned long page_index;
+               extern spinlock_t g_locker;
+               unsigned long g_flags;
+#endif
 
        trace_ext4_write_begin(inode, pos, len, flags);
        /*
@@ -1079,6 +1087,24 @@ retry_journal:
                return ret;
        }
        *pagep = page;
+#if defined(FEATURE_STORAGE_PID_LOGGER)
+               if( page_logger && (*pagep)) {
+                       //#if defined(CONFIG_FLATMEM)
+                       //page_index = (unsigned long)((*pagep) - mem_map) ;
+                       //#else
+                       page_index = (unsigned long)(__page_to_pfn(*pagep))- PHYS_PFN_OFFSET;
+                       //#endif
+                       tmp_logger =((struct page_pid_logger *)page_logger) + page_index;
+                       spin_lock_irqsave(&g_locker, g_flags);
+                       if( page_index < num_physpages) {
+                               if( tmp_logger->pid1 == 0XFFFF)
+                                       tmp_logger->pid1 = current->pid;
+                               else if( tmp_logger->pid1 != current->pid)
+                                       tmp_logger->pid2 = current->pid;
+                       }
+                       spin_unlock_irqrestore(&g_locker, g_flags);
+               }
+#endif
        return ret;
 }
 
@@ -1412,7 +1438,7 @@ static void ext4_da_release_space(struct inode *inode, int to_free)
 static void ext4_da_page_release_reservation(struct page *page,
                                             unsigned long offset)
 {
-       int to_release = 0;
+       int to_release = 0, contiguous_blks = 0;
        struct buffer_head *head, *bh;
        unsigned int curr_off = 0;
        struct inode *inode = page->mapping->host;
@@ -1427,14 +1453,23 @@ static void ext4_da_page_release_reservation(struct page *page,
 
                if ((offset <= curr_off) && (buffer_delay(bh))) {
                        to_release++;
+                       contiguous_blks++;
                        clear_buffer_delay(bh);
+               } else if (contiguous_blks) {
+                       lblk = page->index <<
+                              (PAGE_CACHE_SHIFT - inode->i_blkbits);
+                       lblk += (curr_off >> inode->i_blkbits) -
+                               contiguous_blks;
+                       ext4_es_remove_extent(inode, lblk, contiguous_blks);
+                       contiguous_blks = 0;
                }
                curr_off = next_off;
        } while ((bh = bh->b_this_page) != head);
 
-       if (to_release) {
+       if (contiguous_blks) {
                lblk = page->index << (PAGE_CACHE_SHIFT - inode->i_blkbits);
-               ext4_es_remove_extent(inode, lblk, to_release);
+               lblk += (curr_off >> inode->i_blkbits) - contiguous_blks;
+               ext4_es_remove_extent(inode, lblk, contiguous_blks);
        }
 
        /* If we have released all the blocks belonging to a cluster, then we
@@ -3607,6 +3642,7 @@ int ext4_can_truncate(struct inode *inode)
 
 int ext4_punch_hole(struct file *file, loff_t offset, loff_t length)
 {
+#if 0
        struct inode *inode = file_inode(file);
        struct super_block *sb = inode->i_sb;
        ext4_lblk_t first_block, stop_block;
@@ -3792,6 +3828,12 @@ out_dio:
 out_mutex:
        mutex_unlock(&inode->i_mutex);
        return ret;
+#else
+       /*
+        * Disabled as per b/28760453
+        */
+       return -EOPNOTSUPP;
+#endif
 }
 
 /*
@@ -4054,6 +4096,10 @@ make_io:
                trace_ext4_load_inode(inode);
                get_bh(bh);
                bh->b_end_io = end_buffer_read_sync;
+#ifdef FEATURE_STORAGE_META_LOG
+               if( bh && bh->b_bdev && bh->b_bdev->bd_disk)
+                       set_metadata_rw_status(bh->b_bdev->bd_disk->first_minor, WAIT_READ_CNT);
+#endif
                submit_bh(READ | REQ_META | REQ_PRIO, bh);
                wait_on_buffer(bh);
                if (!buffer_uptodate(bh)) {
@@ -5054,6 +5100,8 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
        might_sleep();
        trace_ext4_mark_inode_dirty(inode, _RET_IP_);
        err = ext4_reserve_inode_write(handle, inode, &iloc);
+       if (err)
+               return err;
        if (ext4_handle_valid(handle) &&
            EXT4_I(inode)->i_extra_isize < sbi->s_want_extra_isize &&
            !ext4_test_inode_state(inode, EXT4_STATE_NO_EXPAND)) {
@@ -5084,9 +5132,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
                        }
                }
        }
-       if (!err)
-               err = ext4_mark_iloc_dirty(handle, inode, &iloc);
-       return err;
+       return ext4_mark_iloc_dirty(handle, inode, &iloc);
 }
 
 /*