~ubuntu-branches/ubuntu/lucid/linux-ec2/lucid-proposed

« back to all changes in this revision

Viewing changes to fs/jbd/transaction.c

  • Committer: Package Import Robot
  • Author(s): Stefan Bader, Stefan Bader, Ubuntu: 2.6.32-49.111
  • Date: 2013-06-19 09:57:14 UTC
  • Revision ID: package-import@ubuntu.com-20130619095714-5zz4z0yt038px5am
Tags: 2.6.32-354.67
[ Stefan Bader ]

* Rebased to Ubuntu-2.6.32-49.111
* SAUCE: ec2: Backport x86/mm: Check if PUD is large when validating a
  kernel address
  - LP: #1193044
* SAUCE: ec2: Backport x86, ioapic: initialize nr_ioapic_registers early
  in mp_register_ioapic()
  - LP: #1193044
* Release Tracking Bug
  - LP: #1193202

[ Ubuntu: 2.6.32-49.111 ]

* Revert "pcdp: use early_ioremap/early_iounmap to access pcdp table"
  - LP: #1193044
* Revert "block: improve queue_should_plug() by looking at IO depths"
  - LP: #1193044
* kernel/signal.c: stop info leak via the tkill and the tgkill syscalls
  - LP: #1187732
  - CVE-2013-2141
* b43: stop format string leaking into error msgs
  - LP: #1189833
  - CVE-2013-2852
* 2.6.32.y: timekeeping: Fix nohz issue with commit
  61b76840ddee647c0c223365378c3f394355b7d7
  - LP: #1193044
* clockevents: Don't allow dummy broadcast timers
  - LP: #1193044
* posix-cpu-timers: Fix nanosleep task_struct leak
  - LP: #1193044
* timer: Don't reinitialize the cpu base lock during CPU_UP_PREPARE
  - LP: #1193044
* tick: Cleanup NOHZ per cpu data on cpu down
  - LP: #1193044
* kbuild: Fix gcc -x syntax
  - LP: #1193044
* gen_init_cpio: avoid stack overflow when expanding
  - LP: #1193044
* coredump: prevent double-free on an error path in core dumper
  - LP: #1193044
* kernel/sys.c: call disable_nonboot_cpus() in kernel_restart()
  - LP: #1193044
* ring-buffer: Fix race between integrity check and readers
  - LP: #1193044
* genalloc: stop crashing the system when destroying a pool
  - LP: #1193044
* kernel/resource.c: fix stack overflow in __reserve_region_with_split()
  - LP: #1193044
* Driver core: treat unregistered bus_types as having no devices
  - LP: #1193044
* cgroup: remove incorrect dget/dput() pair in cgroup_create_dir()
  - LP: #1193044
* Fix a dead loop in async_synchronize_full()
  - LP: #1193044
* tracing: Don't call page_to_pfn() if page is NULL
  - LP: #1193044
* tracing: Fix double free when function profile init failed
  - LP: #1193044
* mm: Fix PageHead when !CONFIG_PAGEFLAGS_EXTENDED
  - LP: #1193044
* mm: bugfix: set current->reclaim_state to NULL while returning from
  kswapd()
  - LP: #1193044
* mm: fix invalidate_complete_page2() lock ordering
  - LP: #1193044
* mempolicy: fix a race in shared_policy_replace()
  - LP: #1193044
* ALSA: hda - More ALC663 fixes and support of compatible chips
  - LP: #1193044
* ALSA: hda - Add a pin-fix for FSC Amilo Pi1505
  - LP: #1193044
* ALSA: seq: Fix missing error handling in snd_seq_timer_open()
  - LP: #1193044
* ALSA: ac97 - Fix missing NULL check in snd_ac97_cvol_new()
  - LP: #1193044
* x86, ioapic: initialize nr_ioapic_registers early in
  mp_register_ioapic()
  - LP: #1193044
* x86: Don't use the EFI reboot method by default
  - LP: #1193044
* x86, random: make ARCH_RANDOM prompt if EMBEDDED, not EXPERT
  - LP: #1193044
* x86/mm: Check if PUD is large when validating a kernel address
  - LP: #1193044
* x86, mm, paravirt: Fix vmalloc_fault oops during lazy MMU updates
  - LP: #1193044
* xen/bootup: allow read_tscp call for Xen PV guests.
  - LP: #1193044
* xen/bootup: allow {read|write}_cr8 pvops call.
  - LP: #1193044
* KVM: x86: relax MSR_KVM_SYSTEM_TIME alignment check
  - LP: #1193044
* KVM: x86: invalid opcode oops on SET_SREGS with OSXSAVE bit set
  (CVE-2012-4461)
  - LP: #1193044
* MCE: Fix vm86 handling for 32bit mce handler
  - LP: #1193044
* ACPI / cpuidle: Fix NULL pointer issues when cpuidle is disabled
  - LP: #1193044
* alpha: Add irongate_io to PCI bus resources
  - LP: #1193044
* PARISC: fix user-triggerable panic on parisc
  - LP: #1193044
* serial: 8250, increase PASS_LIMIT
  - LP: #1193044
* drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory
  overflow
  - LP: #1193044
* w1: fix oops when w1_search is called from netlink connector
  - LP: #1193044
* staging: comedi: ni_labpc: correct differential channel sequence for AI
  commands
  - LP: #1193044
* staging: comedi: ni_labpc: set up command4 register *after* command3
  - LP: #1193044
* staging: comedi: comedi_test: fix race when cancelling command
  - LP: #1193044
* staging: comedi: fix memory leak for saved channel list
  - LP: #1193044
* staging: comedi: s626: don't dereference insn->data
  - LP: #1193044
* staging: comedi: jr3_pci: fix iomem dereference
  - LP: #1193044
* staging: comedi: don't dereference user memory for INSN_INTTRIG
  - LP: #1193044
* staging: comedi: check s->async for poll(), read() and write()
  - LP: #1193044
* staging: comedi: das08: Correct AO output for das08jr-16-ao
  - LP: #1193044
* staging: vt6656: [BUG] out of bound array reference in RFbSetPower.
  - LP: #1193044
* libata: fix Null pointer dereference on disk error
  - LP: #1193044
* scsi: Silence unnecessary warnings about ioctl to partition
  - LP: #1193044
* scsi: use __uX types for headers exported to user space
  - LP: #1193044
* fix crash in scsi_dispatch_cmd()
  - LP: #1193044
* SCSI: bnx2i: Fixed NULL ptr deference for 1G bnx2 Linux iSCSI offload
  - LP: #1193044
* crypto: cryptd - disable softirqs in cryptd_queue_worker to prevent
  data corruption
  - LP: #1193044
* xfrm_user: return error pointer instead of NULL #2
  - LP: #1193044
* r8169: correct settings of rtl8102e.
  - LP: #1193044
* r8169: remove the obsolete and incorrect AMD workaround
  - LP: #1193044
* r8169: Add support for D-Link 530T rev C1 (Kernel Bug 38862)
  - LP: #1193044
* r8169: incorrect identifier for a 8168dp
  - LP: #1193044
* b43legacy: Fix crash on unload when firmware not available
  - LP: #1193044
* tg3: Avoid null pointer dereference in tg3_interrupt in netconsole mode
  - LP: #1193044
* IPoIB: Fix use-after-free of multicast object
  - LP: #1193044
* telephony: ijx: buffer overflow in ixj_write_cid()
  - LP: #1193044
* Bluetooth: HCI - Fix info leak in getsockopt(HCI_FILTER)
  - LP: #1193044
* xhci: Make handover code more robust
  - LP: #1193044
* USB: whiteheat: fix memory leak in error path
  - LP: #1193044
* USB: serial: Fix memory leak in sierra_release()
  - LP: #1193044
* USB: mos7840: fix urb leak at release
  - LP: #1193044
* USB: mos7840: fix port-device leak in error path
  - LP: #1193044
* USB: garmin_gps: fix memory leak on disconnect
  - LP: #1193044
* USB: serial: ftdi_sio: Handle the old_termios == 0 case e.g.
  uart_resume_port()
  - LP: #1193044
* USB: ftdi_sio: Quiet sparse noise about using plain integer was NULL
  pointer
  - LP: #1193044
* epoll: prevent missed events on EPOLL_CTL_MOD
  - LP: #1193044
* fs/fscache/stats.c: fix memory leak
  - LP: #1193044
* sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat()
  - LP: #1193044
* jbd: Delay discarding buffers in journal_unmap_buffer
  - LP: #1193044
* jbd: Fix assertion failure in commit code due to lacking transaction
  credits
  - LP: #1193044
* jbd: Fix lock ordering bug in journal_unmap_buffer()
  - LP: #1193044
* ext4: Fix fs corruption when make_indexed_dir() fails
  - LP: #1193044
* ext4: don't dereference null pointer when make_indexed_dir() fails
  - LP: #1193044
* ext4: fix memory leak in ext4_xattr_set_acl()'s error path
  - LP: #1193044
* ext4: online defrag is not supported for journaled files
  - LP: #1193044
* ext4: always set i_op in ext4_mknod()
  - LP: #1193044
* ext4: fix fdatasync() for files with only i_size changes
  - LP: #1193044
* ext4: lock i_mutex when truncating orphan inodes
  - LP: #1193044
* ext4: fix race in ext4_mb_add_n_trim()
  - LP: #1193044
* ext4: limit group search loop for non-extent files
  - LP: #1193044
* CVE-2012-4508 kernel: ext4: AIO vs fallocate stale data exposure
  - LP: #1193044
  - CVE-2012-4508 kernel: ext4: AIO vs fallocate stale data exposure
* ext4: make orphan functions be no-op in no-journal mode
  - LP: #1193044
* ext4: avoid hang when mounting non-journal filesystems with orphan list
  - LP: #1193044
* udf: fix memory leak while allocating blocks during write
  - LP: #1193044
* udf: Fix bitmap overflow on large filesystems with small block size
  - LP: #1193044
* fs/cifs/cifs_dfs_ref.c: fix potential memory leakage
  - LP: #1193044
* fat: Fix stat->f_namelen
  - LP: #1193044
* hfsplus: fix potential overflow in hfsplus_file_truncate()
  - LP: #1193044
* btrfs: use rcu_barrier() to wait for bdev puts at unmount
  - LP: #1193044
* kernel panic when mount NFSv4
  - LP: #1193044
* nfsd4: fix oops on unusual readlike compound
  - LP: #1193044
* net/core: Fix potential memory leak in dev_set_alias()
  - LP: #1193044
* net: reduce net_rx_action() latency to 2 HZ
  - LP: #1193044
* softirq: reduce latencies
  - LP: #1193044
* af_packet: remove BUG statement in tpacket_destruct_skb
  - LP: #1193044
* bridge: set priority of STP packets
  - LP: #1193044
* bonding: Fix slave selection bug.
  - LP: #1193044
* ipv4: check rt_genid in dst_check
  - LP: #1193044
* net_sched: gact: Fix potential panic in tcf_gact().
  - LP: #1193044
* net: sched: integer overflow fix
  - LP: #1193044
* net: prevent setting ttl=0 via IP_TTL
  - LP: #1193044
* net: guard tcp_set_keepalive() to tcp sockets
  - LP: #1193044
* inet: add RCU protection to inet->opt
  - LP: #1193044
* tcp: allow splice() to build full TSO packets
  - LP: #1193044
* tcp: fix MSG_SENDPAGE_NOTLAST logic
  - LP: #1193044
* tcp: preserve ACK clocking in TSO
  - LP: #1193044
* unix: fix a race condition in unix_release()
  - LP: #1193044
* sctp: fix memory leak in sctp_datamsg_from_user() when copy from user
  space fails
  - LP: #1193044
* net: sctp: sctp_setsockopt_auth_key: use kzfree instead of kfree
  - LP: #1193044
* net: sctp: sctp_endpoint_free: zero out secret key data
  - LP: #1193044
* net: sctp: sctp_auth_key_put: use kzfree instead of kfree
  - LP: #1193044
* netfilter: nf_ct_ipv4: packets with wrong ihl are invalid
  - LP: #1193044
* ipvs: allow transmit of GRO aggregated skbs
  - LP: #1193044
* ipvs: IPv6 MTU checking cleanup and bugfix
  - LP: #1193044
* isdnloop: fix and simplify isdnloop_init()
  - LP: #1193044
* mpt2sas: Send default descriptor for RAID pass through in mpt2ctl
  - LP: #1193044
* x86, ptrace: fix build breakage with gcc 4.7
  - LP: #1193044
* Linux 2.6.32.61
  - LP: #1193044

Show diffs side-by-side

added added

removed removed

Lines of Context:
1838
1838
 * We're outside-transaction here.  Either or both of j_running_transaction
1839
1839
 * and j_committing_transaction may be NULL.
1840
1840
 */
1841
 
static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh)
 
1841
static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
 
1842
                                int partial_page)
1842
1843
{
1843
1844
        transaction_t *transaction;
1844
1845
        struct journal_head *jh;
1845
1846
        int may_free = 1;
1846
 
        int ret;
1847
1847
 
1848
1848
        BUFFER_TRACE(bh, "entry");
1849
1849
 
 
1850
retry:
1850
1851
        /*
1851
1852
         * It is safe to proceed here without the j_list_lock because the
1852
1853
         * buffers cannot be stolen by try_to_free_buffers as long as we are
1864
1865
        if (!jh)
1865
1866
                goto zap_buffer_no_jh;
1866
1867
 
 
1868
        /*
 
1869
         * We cannot remove the buffer from checkpoint lists until the
 
1870
         * transaction adding inode to orphan list (let's call it T)
 
1871
         * is committed.  Otherwise if the transaction changing the
 
1872
         * buffer would be cleaned from the journal before T is
 
1873
         * committed, a crash will cause that the correct contents of
 
1874
         * the buffer will be lost.  On the other hand we have to
 
1875
         * clear the buffer dirty bit at latest at the moment when the
 
1876
         * transaction marking the buffer as freed in the filesystem
 
1877
         * structures is committed because from that moment on the
 
1878
         * block can be reallocated and used by a different page.
 
1879
         * Since the block hasn't been freed yet but the inode has
 
1880
         * already been added to orphan list, it is safe for us to add
 
1881
         * the buffer to BJ_Forget list of the newest transaction.
 
1882
         *
 
1883
         * Also we have to clear buffer_mapped flag of a truncated buffer
 
1884
         * because the buffer_head may be attached to the page straddling
 
1885
         * i_size (can happen only when blocksize < pagesize) and thus the
 
1886
         * buffer_head can be reused when the file is extended again. So we end
 
1887
         * up keeping around invalidated buffers attached to transactions'
 
1888
         * BJ_Forget list just to stop checkpointing code from cleaning up
 
1889
         * the transaction this buffer was modified in.
 
1890
         */
1867
1891
        transaction = jh->b_transaction;
1868
1892
        if (transaction == NULL) {
1869
1893
                /* First case: not on any transaction.  If it
1889
1913
                         * committed, the buffer won't be needed any
1890
1914
                         * longer. */
1891
1915
                        JBUFFER_TRACE(jh, "checkpointed: add to BJ_Forget");
1892
 
                        ret = __dispose_buffer(jh,
 
1916
                        may_free = __dispose_buffer(jh,
1893
1917
                                        journal->j_running_transaction);
1894
 
                        journal_put_journal_head(jh);
1895
 
                        spin_unlock(&journal->j_list_lock);
1896
 
                        jbd_unlock_bh_state(bh);
1897
 
                        spin_unlock(&journal->j_state_lock);
1898
 
                        return ret;
 
1918
                        goto zap_buffer;
1899
1919
                } else {
1900
1920
                        /* There is no currently-running transaction. So the
1901
1921
                         * orphan record which we wrote for this file must have
1903
1923
                         * the committing transaction, if it exists. */
1904
1924
                        if (journal->j_committing_transaction) {
1905
1925
                                JBUFFER_TRACE(jh, "give to committing trans");
1906
 
                                ret = __dispose_buffer(jh,
 
1926
                                may_free = __dispose_buffer(jh,
1907
1927
                                        journal->j_committing_transaction);
1908
 
                                journal_put_journal_head(jh);
1909
 
                                spin_unlock(&journal->j_list_lock);
1910
 
                                jbd_unlock_bh_state(bh);
1911
 
                                spin_unlock(&journal->j_state_lock);
1912
 
                                return ret;
 
1928
                                goto zap_buffer;
1913
1929
                        } else {
1914
1930
                                /* The orphan record's transaction has
1915
1931
                                 * committed.  We can cleanse this buffer */
1929
1945
                        goto zap_buffer;
1930
1946
                }
1931
1947
                /*
1932
 
                 * If it is committing, we simply cannot touch it.  We
1933
 
                 * can remove it's next_transaction pointer from the
1934
 
                 * running transaction if that is set, but nothing
1935
 
                 * else. */
 
1948
                 * The buffer is committing, we simply cannot touch
 
1949
                 * it. If the page is straddling i_size we have to wait
 
1950
                 * for commit and try again.
 
1951
                 */
 
1952
                if (partial_page) {
 
1953
                        tid_t tid = journal->j_committing_transaction->t_tid;
 
1954
 
 
1955
                        journal_put_journal_head(jh);
 
1956
                        spin_unlock(&journal->j_list_lock);
 
1957
                        jbd_unlock_bh_state(bh);
 
1958
                        spin_unlock(&journal->j_state_lock);
 
1959
                        unlock_buffer(bh);
 
1960
                        log_wait_commit(journal, tid);
 
1961
                        lock_buffer(bh);
 
1962
                        goto retry;
 
1963
                }
 
1964
                /*
 
1965
                 * OK, buffer won't be reachable after truncate. We just set
 
1966
                 * j_next_transaction to the running transaction (if there is
 
1967
                 * one) and mark buffer as freed so that commit code knows it
 
1968
                 * should clear dirty bits when it is done with the buffer.
 
1969
                 */
1936
1970
                set_buffer_freed(bh);
1937
 
                if (jh->b_next_transaction) {
1938
 
                        J_ASSERT(jh->b_next_transaction ==
1939
 
                                        journal->j_running_transaction);
1940
 
                        jh->b_next_transaction = NULL;
1941
 
                }
 
1971
                if (journal->j_running_transaction && buffer_jbddirty(bh))
 
1972
                        jh->b_next_transaction = journal->j_running_transaction;
1942
1973
                journal_put_journal_head(jh);
1943
1974
                spin_unlock(&journal->j_list_lock);
1944
1975
                jbd_unlock_bh_state(bh);
1957
1988
        }
1958
1989
 
1959
1990
zap_buffer:
 
1991
        /*
 
1992
         * This is tricky. Although the buffer is truncated, it may be reused
 
1993
         * if blocksize < pagesize and it is attached to the page straddling
 
1994
         * EOF. Since the buffer might have been added to BJ_Forget list of the
 
1995
         * running transaction, journal_get_write_access() won't clear
 
1996
         * b_modified and credit accounting gets confused. So clear b_modified
 
1997
         * here. */
 
1998
        jh->b_modified = 0;
1960
1999
        journal_put_journal_head(jh);
1961
2000
zap_buffer_no_jh:
1962
2001
        spin_unlock(&journal->j_list_lock);
2005
2044
                if (offset <= curr_off) {
2006
2045
                        /* This block is wholly outside the truncation point */
2007
2046
                        lock_buffer(bh);
2008
 
                        may_free &= journal_unmap_buffer(journal, bh);
 
2047
                        may_free &= journal_unmap_buffer(journal, bh,
 
2048
                                                         offset > 0);
2009
2049
                        unlock_buffer(bh);
2010
2050
                }
2011
2051
                curr_off = next_off;
2120
2160
 */
2121
2161
void __journal_refile_buffer(struct journal_head *jh)
2122
2162
{
2123
 
        int was_dirty;
 
2163
        int was_dirty, jlist;
2124
2164
        struct buffer_head *bh = jh2bh(jh);
2125
2165
 
2126
2166
        J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
2142
2182
        __journal_temp_unlink_buffer(jh);
2143
2183
        jh->b_transaction = jh->b_next_transaction;
2144
2184
        jh->b_next_transaction = NULL;
2145
 
        __journal_file_buffer(jh, jh->b_transaction,
2146
 
                                jh->b_modified ? BJ_Metadata : BJ_Reserved);
 
2185
        if (buffer_freed(bh))
 
2186
                jlist = BJ_Forget;
 
2187
        else if (jh->b_modified)
 
2188
                jlist = BJ_Metadata;
 
2189
        else
 
2190
                jlist = BJ_Reserved;
 
2191
        __journal_file_buffer(jh, jh->b_transaction, jlist);
2147
2192
        J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING);
2148
2193
 
2149
2194
        if (was_dirty)