···999999 With this option on every unmap_single operation will10001000 result in a hardware IOTLB flush operation as opposed10011001 to batching them for performance.10021002-10021002+ sp_off [Default Off]10031003+ By default, super page will be supported if Intel IOMMU10041004+ has the capability. With this option, super page will10051005+ not be supported.10031006 intremap= [X86-64, Intel-IOMMU]10041007 Format: { on (default) | off | nosid }10051008 on enable Interrupt Remapping (default)
+1-1
Documentation/virtual/lguest/Makefile
···11# This creates the demonstration utility "lguest" which runs a Linux guest.22-# Missing headers? Add "-I../../include -I../../arch/x86/include"22+# Missing headers? Add "-I../../../include -I../../../arch/x86/include"33CFLAGS:=-m32 -Wall -Wmissing-declarations -Wmissing-prototypes -O3 -U_FORTIFY_SOURCE4455all: lguest
+2-20
Documentation/virtual/lguest/lguest.c
···4949#include <linux/virtio_rng.h>5050#include <linux/virtio_ring.h>5151#include <asm/bootparam.h>5252-#include "../../include/linux/lguest_launcher.h"5252+#include "../../../include/linux/lguest_launcher.h"5353/*L:1105454 * We can ignore the 42 include files we need for this program, but I do want5555 * to draw attention to the use of kernel-style types.···134134135135 /* Is it operational */136136 bool running;137137-138138- /* Does Guest want an intrrupt on empty? */139139- bool irq_on_empty;140137141138 /* Device-specific data. */142139 void *priv;···634637635638 /* If they don't want an interrupt, don't send one... */636639 if (vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT) {637637- /* ... unless they've asked us to force one on empty. */638638- if (!vq->dev->irq_on_empty639639- || lg_last_avail(vq) != vq->vring.avail->idx)640640- return;640640+ return;641641 }642642643643 /* Send the Guest an interrupt tell them we used something up. */···10511057 close(vq->eventfd);10521058}1053105910541054-static bool accepted_feature(struct device *dev, unsigned int bit)10551055-{10561056- const u8 *features = get_feature_bits(dev) + dev->feature_len;10571057-10581058- if (dev->feature_len < bit / CHAR_BIT)10591059- return false;10601060- return features[bit / CHAR_BIT] & (1 << (bit % CHAR_BIT));10611061-}10621062-10631060static void start_device(struct device *dev)10641061{10651062 unsigned int i;···10631078 for (i = 0; i < dev->feature_len; i++)10641079 verbose(" %02x", get_feature_bits(dev)10651080 [dev->feature_len+i]);10661066-10671067- dev->irq_on_empty = accepted_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);1068108110691082 for (vq = dev->vq; vq; vq = vq->next) {10701083 if (vq->service)···15471564 /* Set up the tun device. */15481565 configure_device(ipfd, tapif, ip);1549156615501550- add_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY);15511567 /* Expect Guest to handle everything except UFO */15521568 add_feature(dev, VIRTIO_NET_F_CSUM);15531569 add_feature(dev, VIRTIO_NET_F_GUEST_CSUM);
···715715716716static int __init init_pmacpic_syscore(void)717717{718718- register_syscore_ops(&pmacpic_syscore_ops);718718+ if (pmac_irq_hw[0])719719+ register_syscore_ops(&pmacpic_syscore_ops);719720 return 0;720721}721722
+1-1
arch/sh/Kconfig
···161161162162config NO_IOPORT163163 def_bool !PCI164164- depends on !SH_CAYMAN && !SH_SH4202_MICRODEV164164+ depends on !SH_CAYMAN && !SH_SH4202_MICRODEV && !SH_SHMIN165165166166config IO_TRAPPED167167 bool
···8899ifdef CONFIG_FUNCTION_TRACER1010# Do not profile debug and lowlevel utilities1111+CFLAGS_REMOVE_tsc.o = -pg1112CFLAGS_REMOVE_rtc.o = -pg1213CFLAGS_REMOVE_paravirt-spinlocks.o = -pg1314CFLAGS_REMOVE_pvclock.o = -pg···2928GCOV_PROFILE_vsyscall_64.o := n3029GCOV_PROFILE_hpet.o := n3130GCOV_PROFILE_tsc.o := n3131+GCOV_PROFILE_vread_tsc_64.o := n3232GCOV_PROFILE_paravirt.o := n33333434# vread_tsc_64 is hot and should be fully optimized:
+1-1
arch/x86/kernel/process.c
···642642 boot_option_idle_override = IDLE_POLL;643643 } else if (!strcmp(str, "mwait")) {644644 boot_option_idle_override = IDLE_FORCE_MWAIT;645645- WARN_ONCE(1, "\idle=mwait\" will be removed in 2012\"\n");645645+ WARN_ONCE(1, "\"idle=mwait\" will be removed in 2012\n");646646 } else if (!strcmp(str, "halt")) {647647 /*648648 * When the boot option of idle=halt is added, halt is
+1-1
arch/x86/kernel/smpboot.c
···13321332 void *mwait_ptr;13331333 struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);1334133413351335- if (!this_cpu_has(X86_FEATURE_MWAIT) && mwait_usable(c))13351335+ if (!(this_cpu_has(X86_FEATURE_MWAIT) && mwait_usable(c)))13361336 return;13371337 if (!this_cpu_has(X86_FEATURE_CLFLSH))13381338 return;
+1
arch/x86/lguest/boot.c
···993993static void lguest_time_init(void)994994{995995 /* Set up the timer interrupt (0) to go to our simple timer routine */996996+ lguest_setup_irq(0);996997 irq_set_handler(0, lguest_time_irq);997998998999 clocksource_register_hz(&lguest_clock, NSEC_PER_SEC);
···185185 int nr_cfqq;186186187187 /*188188- * Per group busy queus average. Useful for workload slice calc. We188188+ * Per group busy queues average. Useful for workload slice calc. We189189 * create the array for each prio class but at run time it is used190190 * only for RT and BE class and slot for IDLE class remains unused.191191 * This is primarily done to avoid confusion and a gcc warning.···369369#define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \370370 blk_add_trace_msg((cfqd)->queue, "cfq%d%c %s " fmt, (cfqq)->pid, \371371 cfq_cfqq_sync((cfqq)) ? 'S' : 'A', \372372- blkg_path(&(cfqq)->cfqg->blkg), ##args);372372+ blkg_path(&(cfqq)->cfqg->blkg), ##args)373373374374#define cfq_log_cfqg(cfqd, cfqg, fmt, args...) \375375 blk_add_trace_msg((cfqd)->queue, "%s " fmt, \376376- blkg_path(&(cfqg)->blkg), ##args); \376376+ blkg_path(&(cfqg)->blkg), ##args) \377377378378#else379379#define cfq_log_cfqq(cfqd, cfqq, fmt, args...) \380380 blk_add_trace_msg((cfqd)->queue, "cfq%d " fmt, (cfqq)->pid, ##args)381381-#define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0);381381+#define cfq_log_cfqg(cfqd, cfqg, fmt, args...) do {} while (0)382382#endif383383#define cfq_log(cfqd, fmt, args...) \384384 blk_add_trace_msg((cfqd)->queue, "cfq " fmt, ##args)···37863786 return 0;3787378737883788queue_fail:37893789- if (cic)37903790- put_io_context(cic->ioc);37913791-37923789 cfq_schedule_dispatch(cfqd);37933790 spin_unlock_irqrestore(q->queue_lock, flags);37943791 cfq_log(cfqd, "set_request fail");
+20-2
drivers/block/nbd.c
···192192 if (lo->xmit_timeout)193193 del_timer_sync(&ti);194194 } else195195- result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0);195195+ result = kernel_recvmsg(sock, &msg, &iov, 1, size,196196+ msg.msg_flags);196197197198 if (signal_pending(current)) {198199 siginfo_t info;···754753 return -ENOMEM;755754756755 part_shift = 0;757757- if (max_part > 0)756756+ if (max_part > 0) {758757 part_shift = fls(max_part);758758+759759+ /*760760+ * Adjust max_part according to part_shift as it is exported761761+ * to user space so that user can know the max number of762762+ * partition kernel should be able to manage.763763+ *764764+ * Note that -1 is required because partition 0 is reserved765765+ * for the whole disk.766766+ */767767+ max_part = (1UL << part_shift) - 1;768768+ }769769+770770+ if ((1UL << part_shift) > DISK_MAX_PARTS)771771+ return -EINVAL;772772+773773+ if (nbds_max > 1UL << (MINORBITS - part_shift))774774+ return -EINVAL;759775760776 for (i = 0; i < nbds_max; i++) {761777 struct gendisk *disk = alloc_disk(1 << part_shift);
···66#include <linux/virtio.h>77#include <linux/virtio_blk.h>88#include <linux/scatterlist.h>99+#include <linux/string_helpers.h>1010+#include <scsi/scsi_cmnd.h>9111012#define PART_BITS 411131214static int major, index;1515+struct workqueue_struct *virtblk_wq;13161417struct virtio_blk1518{···2825 struct list_head reqs;29263027 mempool_t *pool;2828+2929+ /* Process context for config space updates */3030+ struct work_struct config_work;31313232 /* What host tells us, plus 2 for header & tailer. */3333 unsigned int sg_elems;···147141 num = blk_rq_map_sg(q, vbr->req, vblk->sg + out);148142149143 if (vbr->req->cmd_type == REQ_TYPE_BLOCK_PC) {150150- sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, 96);144144+ sg_set_buf(&vblk->sg[num + out + in++], vbr->req->sense, SCSI_SENSE_BUFFERSIZE);151145 sg_set_buf(&vblk->sg[num + out + in++], &vbr->in_hdr,152146 sizeof(vbr->in_hdr));153147 }···297291}298292DEVICE_ATTR(serial, S_IRUGO, virtblk_serial_show, NULL);299293294294+static void virtblk_config_changed_work(struct work_struct *work)295295+{296296+ struct virtio_blk *vblk =297297+ container_of(work, struct virtio_blk, config_work);298298+ struct virtio_device *vdev = vblk->vdev;299299+ struct request_queue *q = vblk->disk->queue;300300+ char cap_str_2[10], cap_str_10[10];301301+ u64 capacity, size;302302+303303+ /* Host must always specify the capacity. */304304+ vdev->config->get(vdev, offsetof(struct virtio_blk_config, capacity),305305+ &capacity, sizeof(capacity));306306+307307+ /* If capacity is too big, truncate with warning. */308308+ if ((sector_t)capacity != capacity) {309309+ dev_warn(&vdev->dev, "Capacity %llu too large: truncating\n",310310+ (unsigned long long)capacity);311311+ capacity = (sector_t)-1;312312+ }313313+314314+ size = capacity * queue_logical_block_size(q);315315+ string_get_size(size, STRING_UNITS_2, cap_str_2, sizeof(cap_str_2));316316+ string_get_size(size, STRING_UNITS_10, cap_str_10, sizeof(cap_str_10));317317+318318+ dev_notice(&vdev->dev,319319+ "new size: %llu %d-byte logical blocks (%s/%s)\n",320320+ (unsigned long long)capacity,321321+ queue_logical_block_size(q),322322+ cap_str_10, cap_str_2);323323+324324+ set_capacity(vblk->disk, capacity);325325+}326326+327327+static void virtblk_config_changed(struct virtio_device *vdev)328328+{329329+ struct virtio_blk *vblk = vdev->priv;330330+331331+ queue_work(virtblk_wq, &vblk->config_work);332332+}333333+300334static int __devinit virtblk_probe(struct virtio_device *vdev)301335{302336 struct virtio_blk *vblk;···373327 vblk->vdev = vdev;374328 vblk->sg_elems = sg_elems;375329 sg_init_table(vblk->sg, vblk->sg_elems);330330+ INIT_WORK(&vblk->config_work, virtblk_config_changed_work);376331377332 /* We expect one virtqueue, for output. */378333 vblk->vq = virtio_find_single_vq(vdev, blk_done, "requests");···524477{525478 struct virtio_blk *vblk = vdev->priv;526479480480+ flush_work(&vblk->config_work);481481+527482 /* Nothing should be pending. */528483 BUG_ON(!list_empty(&vblk->reqs));529484···557508 * Use __refdata to avoid this warning.558509 */559510static struct virtio_driver __refdata virtio_blk = {560560- .feature_table = features,561561- .feature_table_size = ARRAY_SIZE(features),562562- .driver.name = KBUILD_MODNAME,563563- .driver.owner = THIS_MODULE,564564- .id_table = id_table,565565- .probe = virtblk_probe,566566- .remove = __devexit_p(virtblk_remove),511511+ .feature_table = features,512512+ .feature_table_size = ARRAY_SIZE(features),513513+ .driver.name = KBUILD_MODNAME,514514+ .driver.owner = THIS_MODULE,515515+ .id_table = id_table,516516+ .probe = virtblk_probe,517517+ .remove = __devexit_p(virtblk_remove),518518+ .config_changed = virtblk_config_changed,567519};568520569521static int __init init(void)570522{523523+ int error;524524+525525+ virtblk_wq = alloc_workqueue("virtio-blk", 0, 0);526526+ if (!virtblk_wq)527527+ return -ENOMEM;528528+571529 major = register_blkdev(0, "virtblk");572572- if (major < 0)573573- return major;574574- return register_virtio_driver(&virtio_blk);530530+ if (major < 0) {531531+ error = major;532532+ goto out_destroy_workqueue;533533+ }534534+535535+ error = register_virtio_driver(&virtio_blk);536536+ if (error)537537+ goto out_unregister_blkdev;538538+ return 0;539539+540540+out_unregister_blkdev:541541+ unregister_blkdev(major, "virtblk");542542+out_destroy_workqueue:543543+ destroy_workqueue(virtblk_wq);544544+ return error;575545}576546577547static void __exit fini(void)578548{579549 unregister_blkdev(major, "virtblk");580550 unregister_virtio_driver(&virtio_blk);551551+ destroy_workqueue(virtblk_wq);581552}582553module_init(init);583554module_exit(fini);
+6-4
drivers/block/xen-blkback/blkback.c
···809809 failed_init:810810 kfree(blkbk->pending_reqs);811811 kfree(blkbk->pending_grant_handles);812812- for (i = 0; i < mmap_pages; i++) {813813- if (blkbk->pending_pages[i])814814- __free_page(blkbk->pending_pages[i]);812812+ if (blkbk->pending_pages) {813813+ for (i = 0; i < mmap_pages; i++) {814814+ if (blkbk->pending_pages[i])815815+ __free_page(blkbk->pending_pages[i]);816816+ }817817+ kfree(blkbk->pending_pages);815818 }816816- kfree(blkbk->pending_pages);817819 kfree(blkbk);818820 blkbk = NULL;819821 return rc;
···296296 * If the TjMax is not plausible, an assumption297297 * will be used298298 */299299- if (val > 80 && val < 120) {299299+ if (val) {300300 dev_info(dev, "TjMax is %d C.\n", val);301301 return val * 1000;302302 }···304304305305 /*306306 * An assumption is made for early CPUs and unreadable MSR.307307- * NOTE: the given value may not be correct.307307+ * NOTE: the calculated value may not be correct.308308 */309309-310310- switch (c->x86_model) {311311- case 0xe:312312- case 0xf:313313- case 0x16:314314- case 0x1a:315315- dev_warn(dev, "TjMax is assumed as 100 C!\n");316316- return 100000;317317- case 0x17:318318- case 0x1c: /* Atom CPUs */319319- return adjust_tjmax(c, id, dev);320320- default:321321- dev_warn(dev, "CPU (model=0x%x) is not supported yet,"322322- " using default TjMax of 100C.\n", c->x86_model);323323- return 100000;324324- }309309+ return adjust_tjmax(c, id, dev);325310}326311327312static void __devinit get_ucode_rev_on_cpu(void *edx)···326341 err = rdmsr_safe_on_cpu(cpu, MSR_IA32_TEMPERATURE_TARGET, &eax, &edx);327342 if (!err) {328343 val = (eax >> 16) & 0xff;329329- if (val > 80 && val < 120)344344+ if (val)330345 return val * 1000;331346 }332347 dev_warn(dev, "Unable to read Pkg-TjMax from CPU:%u\n", cpu);
+18-4
drivers/hwmon/max6642.c
···136136 if (man_id != 0x4D)137137 return -ENODEV;138138139139+ /* sanity check */140140+ if (i2c_smbus_read_byte_data(client, 0x04) != 0x4D141141+ || i2c_smbus_read_byte_data(client, 0x06) != 0x4D142142+ || i2c_smbus_read_byte_data(client, 0xff) != 0x4D)143143+ return -ENODEV;144144+139145 /*140146 * We read the config and status register, the 4 lower bits in the141147 * config register should be zero and bit 5, 3, 1 and 0 should be142148 * zero in the status register.143149 */144150 reg_config = i2c_smbus_read_byte_data(client, MAX6642_REG_R_CONFIG);151151+ if ((reg_config & 0x0f) != 0x00)152152+ return -ENODEV;153153+154154+ /* in between, another round of sanity checks */155155+ if (i2c_smbus_read_byte_data(client, 0x04) != reg_config156156+ || i2c_smbus_read_byte_data(client, 0x06) != reg_config157157+ || i2c_smbus_read_byte_data(client, 0xff) != reg_config)158158+ return -ENODEV;159159+145160 reg_status = i2c_smbus_read_byte_data(client, MAX6642_REG_R_STATUS);146146- if (((reg_config & 0x0f) != 0x00) ||147147- ((reg_status & 0x2b) != 0x00))161161+ if ((reg_status & 0x2b) != 0x00)148162 return -ENODEV;149163150164 strlcpy(info->type, "max6642", I2C_NAME_SIZE);···260246 set_temp_max, 0, MAX6642_REG_W_LOCAL_HIGH);261247static SENSOR_DEVICE_ATTR_2(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,262248 set_temp_max, 1, MAX6642_REG_W_REMOTE_HIGH);263263-static SENSOR_DEVICE_ATTR(temp_fault, S_IRUGO, show_alarm, NULL, 2);249249+static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);264250static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6);265251static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);266252···270256 &sensor_dev_attr_temp1_max.dev_attr.attr,271257 &sensor_dev_attr_temp2_max.dev_attr.attr,272258273273- &sensor_dev_attr_temp_fault.dev_attr.attr,259259+ &sensor_dev_attr_temp2_fault.dev_attr.attr,274260 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,275261 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,276262 NULL
···425425 * in parallel426426 */427427428428-static unsigned int slcan_receive_buf(struct tty_struct *tty,428428+static void slcan_receive_buf(struct tty_struct *tty,429429 const unsigned char *cp, char *fp, int count)430430{431431 struct slcan *sl = (struct slcan *) tty->disc_data;432432- int bytes = count;433432434433 if (!sl || sl->magic != SLCAN_MAGIC || !netif_running(sl->dev))435435- return -ENODEV;434434+ return;436435437436 /* Read the characters out of the buffer */438438- while (bytes--) {437437+ while (count--) {439438 if (fp && *fp++) {440439 if (!test_and_set_bit(SLF_ERROR, &sl->flags))441440 sl->dev->stats.rx_errors++;···443444 }444445 slcan_unesc(sl, *cp++);445446 }446446-447447- return count;448447}449448450449/************************************
+6-4
drivers/net/davinci_emac.c
···17811781 ndev = alloc_etherdev(sizeof(struct emac_priv));17821782 if (!ndev) {17831783 dev_err(&pdev->dev, "error allocating net_device\n");17841784- clk_put(emac_clk);17851785- return -ENOMEM;17841784+ rc = -ENOMEM;17851785+ goto free_clk;17861786 }1787178717881788 platform_set_drvdata(pdev, ndev);···17961796 pdata = pdev->dev.platform_data;17971797 if (!pdata) {17981798 dev_err(&pdev->dev, "no platform data\n");17991799- return -ENODEV;17991799+ rc = -ENODEV;18001800+ goto probe_quit;18001801 }1801180218021803 /* MAC addr and PHY mask , RMII enable info from platform_data */···19301929 iounmap(priv->remap_addr);1931193019321931probe_quit:19331933- clk_put(emac_clk);19341932 free_netdev(ndev);19331933+free_clk:19341934+ clk_put(emac_clk);19351935 return rc;19361936}19371937
+17-18
drivers/net/depca.c
···331331 "DE422",\332332 ""}333333334334-static const char* const depca_signature[] __devinitconst = DEPCA_SIGNATURE;334334+static char* __initdata depca_signature[] = DEPCA_SIGNATURE;335335336336enum depca_type {337337 DEPCA, de100, de101, de200, de201, de202, de210, de212, de422, unknown338338};339339340340-static const char depca_string[] = "depca";340340+static char depca_string[] = "depca";341341342342static int depca_device_remove (struct device *device);343343344344#ifdef CONFIG_EISA345345-static const struct eisa_device_id depca_eisa_ids[] __devinitconst = {345345+static struct eisa_device_id depca_eisa_ids[] = {346346 { "DEC4220", de422 },347347 { "" }348348};···367367#define DE210_ID 0x628d368368#define DE212_ID 0x6def369369370370-static const short depca_mca_adapter_ids[] __devinitconst = {370370+static short depca_mca_adapter_ids[] = {371371 DE210_ID,372372 DE212_ID,373373 0x0000374374};375375376376-static const char *depca_mca_adapter_name[] = {376376+static char *depca_mca_adapter_name[] = {377377 "DEC EtherWORKS MC Adapter (DE210)",378378 "DEC EtherWORKS MC Adapter (DE212)",379379 NULL380380};381381382382-static const enum depca_type depca_mca_adapter_type[] = {382382+static enum depca_type depca_mca_adapter_type[] = {383383 de210,384384 de212,385385 0···541541static int load_packet(struct net_device *dev, struct sk_buff *skb);542542static void depca_dbg_open(struct net_device *dev);543543544544-static const u_char de1xx_irq[] __devinitconst = { 2, 3, 4, 5, 7, 9, 0 };545545-static const u_char de2xx_irq[] __devinitconst = { 5, 9, 10, 11, 15, 0 };546546-static const u_char de422_irq[] __devinitconst = { 5, 9, 10, 11, 0 };544544+static u_char de1xx_irq[] __initdata = { 2, 3, 4, 5, 7, 9, 0 };545545+static u_char de2xx_irq[] __initdata = { 5, 9, 10, 11, 15, 0 };546546+static u_char de422_irq[] __initdata = { 5, 9, 10, 11, 0 };547547+static u_char *depca_irq;547548548549static int irq;549550static int io;···580579 .ndo_validate_addr = eth_validate_addr,581580};582581583583-static int __devinit depca_hw_init (struct net_device *dev, struct device *device)582582+static int __init depca_hw_init (struct net_device *dev, struct device *device)584583{585584 struct depca_private *lp;586585 int i, j, offset, netRAM, mem_len, status = 0;···748747 if (dev->irq < 2) {749748 unsigned char irqnum;750749 unsigned long irq_mask, delay;751751- const u_char *depca_irq;752750753751 irq_mask = probe_irq_on();754752···770770 break;771771772772 default:773773- depca_irq = NULL;774773 break; /* Not reached */775774 }776775···13021303 }13031304}1304130513051305-static int __devinit depca_common_init (u_long ioaddr, struct net_device **devp)13061306+static int __init depca_common_init (u_long ioaddr, struct net_device **devp)13061307{13071308 int status = 0;13081309···13331334/*13341335** Microchannel bus I/O device probe13351336*/13361336-static int __devinit depca_mca_probe(struct device *device)13371337+static int __init depca_mca_probe(struct device *device)13371338{13381339 unsigned char pos[2];13391340 unsigned char where;···14571458** ISA bus I/O device probe14581459*/1459146014601460-static void __devinit depca_platform_probe (void)14611461+static void __init depca_platform_probe (void)14611462{14621463 int i;14631464 struct platform_device *pldev;···14971498 }14981499}1499150015001500-static enum depca_type __devinit depca_shmem_probe (ulong *mem_start)15011501+static enum depca_type __init depca_shmem_probe (ulong *mem_start)15011502{15021503 u_long mem_base[] = DEPCA_RAM_BASE_ADDRESSES;15031504 enum depca_type adapter = unknown;···15581559*/1559156015601561#ifdef CONFIG_EISA15611561-static int __devinit depca_eisa_probe (struct device *device)15621562+static int __init depca_eisa_probe (struct device *device)15621563{15631564 enum depca_type adapter = unknown;15641565 struct eisa_device *edev;···16291630** and Boot (readb) ROM. This will also give us a clue to the network RAM16301631** base address.16311632*/16321632-static int __devinit DepcaSignature(char *name, u_long base_addr)16331633+static int __init DepcaSignature(char *name, u_long base_addr)16331634{16341635 u_int i, j, k;16351636 void __iomem *ptr;
+3-3
drivers/net/dm9000.c
···1157115711581158 irqflags |= IRQF_SHARED;1159115911601160- if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))11611161- return -EAGAIN;11621162-11631160 /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */11641161 iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */11651162 mdelay(1); /* delay needs by DM9000B */···11641167 /* Initialize DM9000 board */11651168 dm9000_reset(db);11661169 dm9000_init_dm9000(dev);11701170+11711171+ if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))11721172+ return -EAGAIN;1167117311681174 /* Init driver variable */11691175 db->dbug_cnt = 0;
+3-5
drivers/net/hamradio/6pack.c
···456456 * a block of 6pack data has been received, which can now be decapsulated457457 * and sent on to some IP layer for further processing.458458 */459459-static unsigned int sixpack_receive_buf(struct tty_struct *tty,459459+static void sixpack_receive_buf(struct tty_struct *tty,460460 const unsigned char *cp, char *fp, int count)461461{462462 struct sixpack *sp;···464464 int count1;465465466466 if (!count)467467- return 0;467467+ return;468468469469 sp = sp_get(tty);470470 if (!sp)471471- return -ENODEV;471471+ return;472472473473 memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf));474474···487487488488 sp_put(sp);489489 tty_unthrottle(tty);490490-491491- return count1;492490}493491494492/*
+4-7
drivers/net/hamradio/mkiss.c
···923923 * a block of data has been received, which can now be decapsulated924924 * and sent on to the AX.25 layer for further processing.925925 */926926-static unsigned int mkiss_receive_buf(struct tty_struct *tty,927927- const unsigned char *cp, char *fp, int count)926926+static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,927927+ char *fp, int count)928928{929929 struct mkiss *ax = mkiss_get(tty);930930- int bytes = count;931930932931 if (!ax)933933- return -ENODEV;932932+ return;934933935934 /*936935 * Argh! mtu change time! - costs us the packet part received···939940 ax_changedmtu(ax);940941941942 /* Read the characters out of the buffer */942942- while (bytes--) {943943+ while (count--) {943944 if (fp != NULL && *fp++) {944945 if (!test_and_set_bit(AXF_ERROR, &ax->flags))945946 ax->dev->stats.rx_errors++;···952953953954 mkiss_put(ax);954955 tty_unthrottle(tty);955955-956956- return count;957956}958957959958/*
+6-6
drivers/net/hp100.c
···188188 * variables189189 */190190#ifdef CONFIG_ISA191191-static const char *const hp100_isa_tbl[] __devinitconst = {191191+static const char *hp100_isa_tbl[] = {192192 "HWPF150", /* HP J2573 rev A */193193 "HWP1950", /* HP J2573 */194194};195195#endif196196197197#ifdef CONFIG_EISA198198-static const struct eisa_device_id hp100_eisa_tbl[] __devinitconst = {198198+static struct eisa_device_id hp100_eisa_tbl[] = {199199 { "HWPF180" }, /* HP J2577 rev A */200200 { "HWP1920" }, /* HP 27248B */201201 { "HWP1940" }, /* HP J2577 */···336336}337337338338#ifdef CONFIG_ISA339339-static __devinit int hp100_isa_probe1(struct net_device *dev, int ioaddr)339339+static __init int hp100_isa_probe1(struct net_device *dev, int ioaddr)340340{341341 const char *sig;342342 int i;···372372 * EISA and PCI are handled by device infrastructure.373373 */374374375375-static int __devinit hp100_isa_probe(struct net_device *dev, int addr)375375+static int __init hp100_isa_probe(struct net_device *dev, int addr)376376{377377 int err = -ENODEV;378378···396396#endif /* CONFIG_ISA */397397398398#if !defined(MODULE) && defined(CONFIG_ISA)399399-struct net_device * __devinit hp100_probe(int unit)399399+struct net_device * __init hp100_probe(int unit)400400{401401 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));402402 int err;···28432843}2844284428452845#ifdef CONFIG_EISA28462846-static int __devinit hp100_eisa_probe (struct device *gendev)28462846+static int __init hp100_eisa_probe (struct device *gendev)28472847{28482848 struct net_device *dev = alloc_etherdev(sizeof(struct hp100_private));28492849 struct eisa_device *edev = to_eisa_device(gendev);
+2-2
drivers/net/ibmlana.c
···895895static int ibmlana_io;896896static int startslot; /* counts through slots when probing multiple devices */897897898898-static const short ibmlana_adapter_ids[] __devinitconst = {898898+static short ibmlana_adapter_ids[] __initdata = {899899 IBM_LANA_ID,900900 0x0000901901};902902903903-static const char *const ibmlana_adapter_names[] __devinitconst = {903903+static char *ibmlana_adapter_names[] __devinitdata = {904904 "IBM LAN Adapter/A",905905 NULL906906};
+7-9
drivers/net/irda/irtty-sir.c
···216216 * usbserial: urb-complete-interrupt / softint217217 */218218219219-static unsigned int irtty_receive_buf(struct tty_struct *tty,220220- const unsigned char *cp, char *fp, int count)219219+static void irtty_receive_buf(struct tty_struct *tty, const unsigned char *cp,220220+ char *fp, int count) 221221{222222 struct sir_dev *dev;223223 struct sirtty_cb *priv = tty->disc_data;224224 int i;225225226226- IRDA_ASSERT(priv != NULL, return -ENODEV;);227227- IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return -EINVAL;);226226+ IRDA_ASSERT(priv != NULL, return;);227227+ IRDA_ASSERT(priv->magic == IRTTY_MAGIC, return;);228228229229 if (unlikely(count==0)) /* yes, this happens */230230- return 0;230230+ return;231231232232 dev = priv->dev;233233 if (!dev) {234234 IRDA_WARNING("%s(), not ready yet!\n", __func__);235235- return -ENODEV;235235+ return;236236 }237237238238 for (i = 0; i < count; i++) {···242242 if (fp && *fp++) { 243243 IRDA_DEBUG(0, "Framing or parity error!\n");244244 sirdev_receive(dev, NULL, 0); /* notify sir_dev (updating stats) */245245- return -EINVAL;245245+ return;246246 }247247 }248248249249 sirdev_receive(dev, cp, count);250250-251251- return count;252250}253251254252/*
+22-22
drivers/net/irda/smsc-ircc2.c
···222222static void smsc_ircc_sir_wait_hw_transmitter_finish(struct smsc_ircc_cb *self);223223224224/* Probing */225225-static int smsc_ircc_look_for_chips(void);226226-static const struct smsc_chip * smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);227227-static int smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);228228-static int smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);229229-static int smsc_superio_fdc(unsigned short cfg_base);230230-static int smsc_superio_lpc(unsigned short cfg_base);225225+static int __init smsc_ircc_look_for_chips(void);226226+static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type);227227+static int __init smsc_superio_flat(const struct smsc_chip *chips, unsigned short cfg_base, char *type);228228+static int __init smsc_superio_paged(const struct smsc_chip *chips, unsigned short cfg_base, char *type);229229+static int __init smsc_superio_fdc(unsigned short cfg_base);230230+static int __init smsc_superio_lpc(unsigned short cfg_base);231231#ifdef CONFIG_PCI232232-static int preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);233233-static int preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);234234-static void preconfigure_ali_port(struct pci_dev *dev,232232+static int __init preconfigure_smsc_chip(struct smsc_ircc_subsystem_configuration *conf);233233+static int __init preconfigure_through_82801(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);234234+static void __init preconfigure_ali_port(struct pci_dev *dev,235235 unsigned short port);236236-static int preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);237237-static int smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,236236+static int __init preconfigure_through_ali(struct pci_dev *dev, struct smsc_ircc_subsystem_configuration *conf);237237+static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,238238 unsigned short ircc_fir,239239 unsigned short ircc_sir,240240 unsigned char ircc_dma,···366366}367367368368/* PNP hotplug support */369369-static const struct pnp_device_id smsc_ircc_pnp_table[] __devinitconst = {369369+static const struct pnp_device_id smsc_ircc_pnp_table[] = {370370 { .id = "SMCf010", .driver_data = 0 },371371 /* and presumably others */372372 { }···515515 * Try to open driver instance516516 *517517 */518518-static int __devinit smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)518518+static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u8 dma, u8 irq)519519{520520 struct smsc_ircc_cb *self;521521 struct net_device *dev;···22732273}227422742275227522762276-static int __devinit smsc_access(unsigned short cfg_base, unsigned char reg)22762276+static int __init smsc_access(unsigned short cfg_base, unsigned char reg)22772277{22782278 IRDA_DEBUG(1, "%s\n", __func__);22792279···22812281 return inb(cfg_base) != reg ? -1 : 0;22822282}2283228322842284-static const struct smsc_chip * __devinit smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)22842284+static const struct smsc_chip * __init smsc_ircc_probe(unsigned short cfg_base, u8 reg, const struct smsc_chip *chip, char *type)22852285{22862286 u8 devid, xdevid, rev;22872287···24062406#ifdef CONFIG_PCI24072407#define PCIID_VENDOR_INTEL 0x808624082408#define PCIID_VENDOR_ALI 0x10b924092409-static const struct smsc_ircc_subsystem_configuration subsystem_configurations[] __devinitconst = {24092409+static struct smsc_ircc_subsystem_configuration subsystem_configurations[] __initdata = {24102410 /*24112411 * Subsystems needing entries:24122412 * 0x10b9:0x1533 0x103c:0x0850 HP nx9010 family···25322532 * (FIR port, SIR port, FIR DMA, FIR IRQ)25332533 * through the chip configuration port.25342534 */25352535-static int __devinit preconfigure_smsc_chip(struct25352535+static int __init preconfigure_smsc_chip(struct25362536 smsc_ircc_subsystem_configuration25372537 *conf)25382538{···26332633 * or Intel 82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge.26342634 * They all work the same way!26352635 */26362636-static int __devinit preconfigure_through_82801(struct pci_dev *dev,26362636+static int __init preconfigure_through_82801(struct pci_dev *dev,26372637 struct26382638 smsc_ircc_subsystem_configuration26392639 *conf)···27862786 * This is based on reverse-engineering since ALi does not27872787 * provide any data sheet for the 1533 chip.27882788 */27892789-static void __devinit preconfigure_ali_port(struct pci_dev *dev,27892789+static void __init preconfigure_ali_port(struct pci_dev *dev,27902790 unsigned short port)27912791{27922792 unsigned char reg;···28242824 IRDA_MESSAGE("Activated ALi 1533 ISA bridge port 0x%04x.\n", port);28252825}2826282628272827-static int __devinit preconfigure_through_ali(struct pci_dev *dev,28272827+static int __init preconfigure_through_ali(struct pci_dev *dev,28282828 struct28292829 smsc_ircc_subsystem_configuration28302830 *conf)···28372837 return preconfigure_smsc_chip(conf);28382838}2839283928402840-static int __devinit smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,28402840+static int __init smsc_ircc_preconfigure_subsystems(unsigned short ircc_cfg,28412841 unsigned short ircc_fir,28422842 unsigned short ircc_sir,28432843 unsigned char ircc_dma,···28492849 int ret = 0;2850285028512851 for_each_pci_dev(dev) {28522852- const struct smsc_ircc_subsystem_configuration *conf;28522852+ struct smsc_ircc_subsystem_configuration *conf;2853285328542854 /*28552855 * Cache the subsystem vendor/device:
+1-1
drivers/net/ks8842.c
···661661662662 /* check the status */663663 if ((status & RXSR_VALID) && !(status & RXSR_ERROR)) {664664- struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len);664664+ struct sk_buff *skb = netdev_alloc_skb_ip_align(netdev, len + 3);665665666666 if (skb) {667667
···340340}341341342342/* May sleep, don't call from interrupt level or with interrupts disabled */343343-static unsigned int343343+static void344344ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf,345345 char *cflags, int count)346346{···348348 unsigned long flags;349349350350 if (!ap)351351- return -ENODEV;351351+ return;352352 spin_lock_irqsave(&ap->recv_lock, flags);353353 ppp_async_input(ap, buf, cflags, count);354354 spin_unlock_irqrestore(&ap->recv_lock, flags);···356356 tasklet_schedule(&ap->tsk);357357 ap_put(ap);358358 tty_unthrottle(tty);359359-360360- return count;361359}362360363361static void
+2-4
drivers/net/ppp_synctty.c
···381381}382382383383/* May sleep, don't call from interrupt level or with interrupts disabled */384384-static unsigned int384384+static void385385ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf,386386 char *cflags, int count)387387{···389389 unsigned long flags;390390391391 if (!ap)392392- return -ENODEV;392392+ return;393393 spin_lock_irqsave(&ap->recv_lock, flags);394394 ppp_sync_input(ap, buf, cflags, count);395395 spin_unlock_irqrestore(&ap->recv_lock, flags);···397397 tasklet_schedule(&ap->tsk);398398 sp_put(ap);399399 tty_unthrottle(tty);400400-401401- return count;402400}403401404402static void
+4-7
drivers/net/slip.c
···670670 * in parallel671671 */672672673673-static unsigned int slip_receive_buf(struct tty_struct *tty,674674- const unsigned char *cp, char *fp, int count)673673+static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,674674+ char *fp, int count)675675{676676 struct slip *sl = tty->disc_data;677677- int bytes = count;678677679678 if (!sl || sl->magic != SLIP_MAGIC || !netif_running(sl->dev))680680- return -ENODEV;679679+ return;681680682681 /* Read the characters out of the buffer */683683- while (bytes--) {682682+ while (count--) {684683 if (fp && *fp++) {685684 if (!test_and_set_bit(SLF_ERROR, &sl->flags))686685 sl->dev->stats.rx_errors++;···693694#endif694695 slip_unesc(sl, *cp++);695696 }696696-697697- return count;698697}699698700699/************************************
+3-3
drivers/net/smc-mca.c
···156156 { 14, 15 }157157};158158159159-static const short smc_mca_adapter_ids[] __devinitconst = {159159+static short smc_mca_adapter_ids[] __initdata = {160160 0x61c8,161161 0x61c9,162162 0x6fc0,···168168 0x0000169169};170170171171-static const char *const smc_mca_adapter_names[] __devinitconst = {171171+static char *smc_mca_adapter_names[] __initdata = {172172 "SMC Ethercard PLUS Elite/A BNC/AUI (WD8013EP/A)",173173 "SMC Ethercard PLUS Elite/A UTP/AUI (WD8013WP/A)",174174 "WD Ethercard PLUS/A (WD8003E/A or WD8003ET/A)",···199199#endif200200};201201202202-static int __devinit ultramca_probe(struct device *gen_dev)202202+static int __init ultramca_probe(struct device *gen_dev)203203{204204 unsigned short ioaddr;205205 struct net_device *dev;
+1-1
drivers/net/tg3.c
···57745774 dma_unmap_addr(txb, mapping),57755775 skb_headlen(skb),57765776 PCI_DMA_TODEVICE);57775777- for (i = 0; i <= last; i++) {57775777+ for (i = 0; i < last; i++) {57785778 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];5779577957805780 entry = NEXT_TX(entry);
+1-1
drivers/net/tokenring/madgemc.c
···727727 return 0;728728}729729730730-static const short madgemc_adapter_ids[] __devinitconst = {730730+static short madgemc_adapter_ids[] __initdata = {731731 0x002d,732732 0x0000733733};
···609609 * before it gets out of hand. Naturally, this wastes entries. */610610 if (capacity < 2+MAX_SKB_FRAGS) {611611 netif_stop_queue(dev);612612- if (unlikely(!virtqueue_enable_cb(vi->svq))) {612612+ if (unlikely(!virtqueue_enable_cb_delayed(vi->svq))) {613613 /* More just got used, free them then recheck. */614614 capacity += free_old_xmit_skbs(vi);615615 if (capacity >= 2+MAX_SKB_FRAGS) {
+2-5
drivers/net/wan/x25_asy.c
···517517 * and sent on to some IP layer for further processing.518518 */519519520520-static unsigned int x25_asy_receive_buf(struct tty_struct *tty,520520+static void x25_asy_receive_buf(struct tty_struct *tty,521521 const unsigned char *cp, char *fp, int count)522522{523523 struct x25_asy *sl = tty->disc_data;524524- int bytes = count;525524526525 if (!sl || sl->magic != X25_ASY_MAGIC || !netif_running(sl->dev))527526 return;528527529528530529 /* Read the characters out of the buffer */531531- while (bytes--) {530530+ while (count--) {532531 if (fp && *fp++) {533532 if (!test_and_set_bit(SLF_ERROR, &sl->flags))534533 sl->dev->stats.rx_errors++;···536537 }537538 x25_asy_unesc(sl, *cp++);538539 }539539-540540- return count;541540}542541543542/*
-1
drivers/net/wireless/ath/ath9k/Kconfig
···2626config ATH9K_PCI2727 bool "Atheros ath9k PCI/PCIe bus support"2828 depends on ATH9K && PCI2929- default PCI3029 ---help---3130 This option enables the PCI bus support in ath9k.3231
+1-1
drivers/net/wireless/ath/ath9k/ar9002_calib.c
···829829 if (AR_SREV_9271(ah)) {830830 if (!ar9285_hw_cl_cal(ah, chan))831831 return false;832832- } else if (AR_SREV_9285_12_OR_LATER(ah)) {832832+ } else if (AR_SREV_9285(ah) && AR_SREV_9285_12_OR_LATER(ah)) {833833 if (!ar9285_hw_clc(ah, chan))834834 return false;835835 } else {
+8-2
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
···46454645 case 1:46464646 break;46474647 case 2:46484648- scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;46484648+ if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)46494649+ scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;46504650+ else46514651+ scaledPower = 0;46494652 break;46504653 case 3:46514651- scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;46544654+ if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)46554655+ scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;46564656+ else46574657+ scaledPower = 0;46524658 break;46534659 }46544660
+22
drivers/net/wireless/ath/ath9k/ar9003_phy.c
···13811381 "==== BB update: done ====\n\n");13821382}13831383EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info);13841384+13851385+void ar9003_hw_disable_phy_restart(struct ath_hw *ah)13861386+{13871387+ u32 val;13881388+13891389+ /* While receiving unsupported rate frame rx state machine13901390+ * gets into a state 0xb and if phy_restart happens in that13911391+ * state, BB would go hang. If RXSM is in 0xb state after13921392+ * first bb panic, ensure to disable the phy_restart.13931393+ */13941394+ if (!((MS(ah->bb_watchdog_last_status,13951395+ AR_PHY_WATCHDOG_RX_OFDM_SM) == 0xb) ||13961396+ ah->bb_hang_rx_ofdm))13971397+ return;13981398+13991399+ ah->bb_hang_rx_ofdm = true;14001400+ val = REG_READ(ah, AR_PHY_RESTART);14011401+ val &= ~AR_PHY_RESTART_ENA;14021402+14031403+ REG_WRITE(ah, AR_PHY_RESTART, val);14041404+}14051405+EXPORT_SYMBOL(ar9003_hw_disable_phy_restart);
+8-2
drivers/net/wireless/ath/ath9k/eeprom_9287.c
···524524 case 1:525525 break;526526 case 2:527527- scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;527527+ if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)528528+ scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;529529+ else530530+ scaledPower = 0;528531 break;529532 case 3:530530- scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;533533+ if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)534534+ scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;535535+ else536536+ scaledPower = 0;531537 break;532538 }533539 scaledPower = max((u16)0, scaledPower);
+4-1
drivers/net/wireless/ath/ath9k/hw.c
···15551555 if (ah->btcoex_hw.enabled)15561556 ath9k_hw_btcoex_enable(ah);1557155715581558- if (AR_SREV_9300_20_OR_LATER(ah))15581558+ if (AR_SREV_9300_20_OR_LATER(ah)) {15591559 ar9003_hw_bb_watchdog_config(ah);15601560+15611561+ ar9003_hw_disable_phy_restart(ah);15621562+ }1560156315611564 ath9k_hw_apply_gpio_override(ah);15621565
+2
drivers/net/wireless/ath/ath9k/hw.h
···842842843843 u32 bb_watchdog_last_status;844844 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */845845+ u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */845846846847 unsigned int paprd_target_power;847848 unsigned int paprd_training_power;···991990void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);992991void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);993992void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);993993+void ar9003_hw_disable_phy_restart(struct ath_hw *ah);994994void ar9003_paprd_enable(struct ath_hw *ah, bool val);995995void ar9003_paprd_populate_single_table(struct ath_hw *ah,996996 struct ath9k_hw_cal_data *caldata,
···994994 cmd = cmdnode->cmdbuf;995995996996 spin_lock_irqsave(&priv->driver_lock, flags);997997+ priv->seqnum++;998998+ cmd->seqnum = cpu_to_le16(priv->seqnum);997999 priv->cur_cmd = cmdnode;9981000 spin_unlock_irqrestore(&priv->driver_lock, flags);9991001···16231621 /* Copy the incoming command to the buffer */16241622 memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size);1625162316261626- /* Set sequence number, clean result, move to buffer */16271627- priv->seqnum++;16241624+ /* Set command, clean result, move to buffer */16281625 cmdnode->cmdbuf->command = cpu_to_le16(command);16291626 cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size);16301630- cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum);16311627 cmdnode->cmdbuf->result = 0;1632162816331629 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
+2-2
drivers/net/wireless/mwifiex/sdio.h
···167167/* Rx unit register */168168#define CARD_RX_UNIT_REG 0x63169169170170-/* Event header Len*/171171-#define MWIFIEX_EVENT_HEADER_LEN 8170170+/* Event header len w/o 4 bytes of interface header */171171+#define MWIFIEX_EVENT_HEADER_LEN 4172172173173/* Max retry number of CMD53 write */174174#define MAX_WRITE_IOMEM_RETRY 2
-1
drivers/net/wireless/rt2x00/Kconfig
···166166config RT2800USB_RT53XX167167 bool "rt2800usb - Include support for rt53xx devices (EXPERIMENTAL)"168168 depends on EXPERIMENTAL169169- default y170169 ---help---171170 This adds support for rt53xx wireless chipset family to the172171 rt2800pci driver.
+22-13
drivers/net/wireless/rtlwifi/pci.c
···669669 &rx_status,670670 (u8 *) pdesc, skb);671671672672- pci_unmap_single(rtlpci->pdev,673673- *((dma_addr_t *) skb->cb),674674- rtlpci->rxbuffersize,675675- PCI_DMA_FROMDEVICE);676676-677672 skb_put(skb, rtlpriv->cfg->ops->get_desc((u8 *) pdesc,678673 false,679674 HW_DESC_RXPKT_LEN));···684689685690 hdr = rtl_get_hdr(skb);686691 fc = rtl_get_fc(skb);692692+693693+ /* try for new buffer - if allocation fails, drop694694+ * frame and reuse old buffer695695+ */696696+ new_skb = dev_alloc_skb(rtlpci->rxbuffersize);697697+ if (unlikely(!new_skb)) {698698+ RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),699699+ DBG_DMESG,700700+ ("can't alloc skb for rx\n"));701701+ goto done;702702+ }703703+ pci_unmap_single(rtlpci->pdev,704704+ *((dma_addr_t *) skb->cb),705705+ rtlpci->rxbuffersize,706706+ PCI_DMA_FROMDEVICE);687707688708 if (!stats.crc || !stats.hwerror) {689709 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status,···768758 rtl_lps_leave(hw);769759 }770760771771- new_skb = dev_alloc_skb(rtlpci->rxbuffersize);772772- if (unlikely(!new_skb)) {773773- RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),774774- DBG_DMESG,775775- ("can't alloc skb for rx\n"));776776- goto done;777777- }778761 skb = new_skb;779779- /*skb->dev = dev; */780762781763 rtlpci->rx_ring[rx_queue_idx].rx_buf[rtlpci->782764 rx_ring···11141112 rtlpci->rxringcount);1115111311161114 rtlpci->rx_ring[rx_queue_idx].idx = 0;11151115+11161116+ /* If amsdu_8k is disabled, set buffersize to 4096. This11171117+ * change will reduce memory fragmentation.11181118+ */11191119+ if (rtlpci->rxbuffersize > 4096 &&11201120+ rtlpriv->rtlhal.disable_amsdu_8k)11211121+ rtlpci->rxbuffersize = 4096;1117112211181123 for (i = 0; i < rtlpci->rxringcount; i++) {11191124 struct sk_buff *skb =
+3
drivers/net/wireless/wl12xx/conf.h
···11571157 /* time to wait on the channel for passive scans (in TUs) */11581158 u32 dwell_time_passive;1159115911601160+ /* time to wait on the channel for DFS scans (in TUs) */11611161+ u32 dwell_time_dfs;11621162+11601163 /* number of probe requests to send on each channel in active scans */11611164 u8 num_probe_reqs;11621165
···15331533module_init(usb_init);15341534module_exit(usb_exit);1535153515361536+static int zd_ep_regs_out_msg(struct usb_device *udev, void *data, int len,15371537+ int *actual_length, int timeout)15381538+{15391539+ /* In USB 2.0 mode EP_REGS_OUT endpoint is interrupt type. However in15401540+ * USB 1.1 mode endpoint is bulk. Select correct type URB by endpoint15411541+ * descriptor.15421542+ */15431543+ struct usb_host_endpoint *ep;15441544+ unsigned int pipe;15451545+15461546+ pipe = usb_sndintpipe(udev, EP_REGS_OUT);15471547+ ep = usb_pipe_endpoint(udev, pipe);15481548+ if (!ep)15491549+ return -EINVAL;15501550+15511551+ if (usb_endpoint_xfer_int(&ep->desc)) {15521552+ return usb_interrupt_msg(udev, pipe, data, len,15531553+ actual_length, timeout);15541554+ } else {15551555+ pipe = usb_sndbulkpipe(udev, EP_REGS_OUT);15561556+ return usb_bulk_msg(udev, pipe, data, len, actual_length,15571557+ timeout);15581558+ }15591559+}15601560+15361561static int usb_int_regs_length(unsigned int count)15371562{15381563 return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);···1673164816741649 udev = zd_usb_to_usbdev(usb);16751650 prepare_read_regs_int(usb);16761676- r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT),16771677- req, req_len, &actual_req_len, 50 /* ms */);16511651+ r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/);16781652 if (r) {16791653 dev_dbg_f(zd_usb_dev(usb),16801680- "error in usb_interrupt_msg(). Error number %d\n", r);16541654+ "error in zd_ep_regs_out_msg(). Error number %d\n", r);16811655 goto error;16821656 }16831657 if (req_len != actual_req_len) {16841684- dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()\n"16581658+ dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()\n"16851659 " req_len %d != actual_req_len %d\n",16861660 req_len, actual_req_len);16871661 r = -EIO;···18421818 rw->value = cpu_to_le16(ioreqs[i].value);18431819 }1844182018451845- usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT),18461846- req, req_len, iowrite16v_urb_complete, usb,18471847- ep->desc.bInterval);18211821+ /* In USB 2.0 mode endpoint is interrupt type. However in USB 1.1 mode18221822+ * endpoint is bulk. Select correct type URB by endpoint descriptor.18231823+ */18241824+ if (usb_endpoint_xfer_int(&ep->desc))18251825+ usb_fill_int_urb(urb, udev, usb_sndintpipe(udev, EP_REGS_OUT),18261826+ req, req_len, iowrite16v_urb_complete, usb,18271827+ ep->desc.bInterval);18281828+ else18291829+ usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_REGS_OUT),18301830+ req, req_len, iowrite16v_urb_complete, usb);18311831+18481832 urb->transfer_flags |= URB_FREE_BUFFER;1849183318501834 /* Submit previous URB */···19561924 }1957192519581926 udev = zd_usb_to_usbdev(usb);19591959- r = usb_interrupt_msg(udev, usb_sndintpipe(udev, EP_REGS_OUT),19601960- req, req_len, &actual_req_len, 50 /* ms */);19271927+ r = zd_ep_regs_out_msg(udev, req, req_len, &actual_req_len, 50 /*ms*/);19611928 if (r) {19621929 dev_dbg_f(zd_usb_dev(usb),19631963- "error in usb_interrupt_msg(). Error number %d\n", r);19301930+ "error in zd_ep_regs_out_msg(). Error number %d\n", r);19641931 goto out;19651932 }19661933 if (req_len != actual_req_len) {19671967- dev_dbg_f(zd_usb_dev(usb), "error in usb_interrupt_msg()"19341934+ dev_dbg_f(zd_usb_dev(usb), "error in zd_ep_regs_out_msg()"19681935 " req_len %d != actual_req_len %d\n",19691936 req_len, actual_req_len);19701937 r = -EIO;
+1-6
drivers/pci/dmar.c
···698698 {699699#ifdef CONFIG_INTR_REMAP700700 struct acpi_table_dmar *dmar;701701- /*702702- * for now we will disable dma-remapping when interrupt703703- * remapping is enabled.704704- * When support for queued invalidation for IOTLB invalidation705705- * is added, we will not need this any more.706706- */701701+707702 dmar = (struct acpi_table_dmar *) dmar_tbl;708703 if (ret && cpu_has_x2apic && dmar->flags & 0x1)709704 printk(KERN_INFO
+201-39
drivers/pci/intel-iommu.c
···4747#define ROOT_SIZE VTD_PAGE_SIZE4848#define CONTEXT_SIZE VTD_PAGE_SIZE49495050+#define IS_BRIDGE_HOST_DEVICE(pdev) \5151+ ((pdev->class >> 8) == PCI_CLASS_BRIDGE_HOST)5052#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)5153#define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA)5254#define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e)···118116 return (pfn + level_size(level) - 1) & level_mask(level);119117}120118119119+static inline unsigned long lvl_to_nr_pages(unsigned int lvl)120120+{121121+ return 1 << ((lvl - 1) * LEVEL_STRIDE);122122+}123123+121124/* VT-d pages must always be _smaller_ than MM pages. Otherwise things122125 are never going to work. */123126static inline unsigned long dma_to_mm_pfn(unsigned long dma_pfn)···148141149142static void __init check_tylersburg_isoch(void);150143static int rwbf_quirk;144144+145145+/*146146+ * set to 1 to panic kernel if can't successfully enable VT-d147147+ * (used when kernel is launched w/ TXT)148148+ */149149+static int force_on = 0;151150152151/*153152 * 0: Present···351338 int iommu_coherency;/* indicate coherency of iommu access */352339 int iommu_snooping; /* indicate snooping control feature*/353340 int iommu_count; /* reference count of iommu */341341+ int iommu_superpage;/* Level of superpages supported:342342+ 0 == 4KiB (no superpages), 1 == 2MiB,343343+ 2 == 1GiB, 3 == 512GiB, 4 == 1TiB */354344 spinlock_t iommu_lock; /* protect iommu set in domain */355345 u64 max_addr; /* maximum mapped address */356346};···403387static int dmar_map_gfx = 1;404388static int dmar_forcedac;405389static int intel_iommu_strict;390390+static int intel_iommu_superpage = 1;406391407392#define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1))408393static DEFINE_SPINLOCK(device_domain_lock);···434417 printk(KERN_INFO435418 "Intel-IOMMU: disable batched IOTLB flush\n");436419 intel_iommu_strict = 1;420420+ } else if (!strncmp(str, "sp_off", 6)) {421421+ printk(KERN_INFO422422+ "Intel-IOMMU: disable supported super page\n");423423+ intel_iommu_superpage = 0;437424 }438425439426 str += strcspn(str, ",");···576555 }577556}578557558558+static void domain_update_iommu_superpage(struct dmar_domain *domain)559559+{560560+ int i, mask = 0xf;561561+562562+ if (!intel_iommu_superpage) {563563+ domain->iommu_superpage = 0;564564+ return;565565+ }566566+567567+ domain->iommu_superpage = 4; /* 1TiB */568568+569569+ for_each_set_bit(i, &domain->iommu_bmp, g_num_of_iommus) {570570+ mask |= cap_super_page_val(g_iommus[i]->cap);571571+ if (!mask) {572572+ break;573573+ }574574+ }575575+ domain->iommu_superpage = fls(mask);576576+}577577+579578/* Some capabilities may be different across iommus */580579static void domain_update_iommu_cap(struct dmar_domain *domain)581580{582581 domain_update_iommu_coherency(domain);583582 domain_update_iommu_snooping(domain);583583+ domain_update_iommu_superpage(domain);584584}585585586586static struct intel_iommu *device_to_iommu(int segment, u8 bus, u8 devfn)···731689}732690733691static struct dma_pte *pfn_to_dma_pte(struct dmar_domain *domain,734734- unsigned long pfn)692692+ unsigned long pfn, int large_level)735693{736694 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;737695 struct dma_pte *parent, *pte = NULL;738696 int level = agaw_to_level(domain->agaw);739739- int offset;697697+ int offset, target_level;740698741699 BUG_ON(!domain->pgd);742700 BUG_ON(addr_width < BITS_PER_LONG && pfn >> addr_width);743701 parent = domain->pgd;702702+703703+ /* Search pte */704704+ if (!large_level)705705+ target_level = 1;706706+ else707707+ target_level = large_level;744708745709 while (level > 0) {746710 void *tmp_page;747711748712 offset = pfn_level_offset(pfn, level);749713 pte = &parent[offset];750750- if (level == 1)714714+ if (!large_level && (pte->val & DMA_PTE_LARGE_PAGE))715715+ break;716716+ if (level == target_level)751717 break;752718753719 if (!dma_pte_present(pte)) {···783733 return pte;784734}785735736736+786737/* return address's pte at specific level */787738static struct dma_pte *dma_pfn_level_pte(struct dmar_domain *domain,788739 unsigned long pfn,789789- int level)740740+ int level, int *large_page)790741{791742 struct dma_pte *parent, *pte = NULL;792743 int total = agaw_to_level(domain->agaw);···800749 if (level == total)801750 return pte;802751803803- if (!dma_pte_present(pte))752752+ if (!dma_pte_present(pte)) {753753+ *large_page = total;804754 break;755755+ }756756+757757+ if (pte->val & DMA_PTE_LARGE_PAGE) {758758+ *large_page = total;759759+ return pte;760760+ }761761+805762 parent = phys_to_virt(dma_pte_addr(pte));806763 total--;807764 }···822763 unsigned long last_pfn)823764{824765 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;766766+ unsigned int large_page = 1;825767 struct dma_pte *first_pte, *pte;826768827769 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);···831771832772 /* we don't need lock here; nobody else touches the iova range */833773 do {834834- first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1);774774+ large_page = 1;775775+ first_pte = pte = dma_pfn_level_pte(domain, start_pfn, 1, &large_page);835776 if (!pte) {836836- start_pfn = align_to_level(start_pfn + 1, 2);777777+ start_pfn = align_to_level(start_pfn + 1, large_page + 1);837778 continue;838779 }839839- do { 780780+ do {840781 dma_clear_pte(pte);841841- start_pfn++;782782+ start_pfn += lvl_to_nr_pages(large_page);842783 pte++;843784 } while (start_pfn <= last_pfn && !first_pte_in_page(pte));844785···859798 int total = agaw_to_level(domain->agaw);860799 int level;861800 unsigned long tmp;801801+ int large_page = 2;862802863803 BUG_ON(addr_width < BITS_PER_LONG && start_pfn >> addr_width);864804 BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);···875813 return;876814877815 do {878878- first_pte = pte = dma_pfn_level_pte(domain, tmp, level);816816+ large_page = level;817817+ first_pte = pte = dma_pfn_level_pte(domain, tmp, level, &large_page);818818+ if (large_page > level)819819+ level = large_page + 1;879820 if (!pte) {880821 tmp = align_to_level(tmp + 1, level + 1);881822 continue;···14621397 else14631398 domain->iommu_snooping = 0;1464139914001400+ domain->iommu_superpage = fls(cap_super_page_val(iommu->cap));14651401 domain->iommu_count = 1;14661402 domain->nid = iommu->node;14671403···14821416 /* Domain 0 is reserved, so dont process it */14831417 if (!domain)14841418 return;14191419+14201420+ /* Flush any lazy unmaps that may reference this domain */14211421+ if (!intel_iommu_strict)14221422+ flush_unmaps_timeout(0);1485142314861424 domain_remove_dev_info(domain);14871425 /* destroy iovas */···17181648 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;17191649}1720165016511651+/* Return largest possible superpage level for a given mapping */16521652+static inline int hardware_largepage_caps(struct dmar_domain *domain,16531653+ unsigned long iov_pfn,16541654+ unsigned long phy_pfn,16551655+ unsigned long pages)16561656+{16571657+ int support, level = 1;16581658+ unsigned long pfnmerge;16591659+16601660+ support = domain->iommu_superpage;16611661+16621662+ /* To use a large page, the virtual *and* physical addresses16631663+ must be aligned to 2MiB/1GiB/etc. Lower bits set in either16641664+ of them will mean we have to use smaller pages. So just16651665+ merge them and check both at once. */16661666+ pfnmerge = iov_pfn | phy_pfn;16671667+16681668+ while (support && !(pfnmerge & ~VTD_STRIDE_MASK)) {16691669+ pages >>= VTD_STRIDE_SHIFT;16701670+ if (!pages)16711671+ break;16721672+ pfnmerge >>= VTD_STRIDE_SHIFT;16731673+ level++;16741674+ support--;16751675+ }16761676+ return level;16771677+}16781678+17211679static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,17221680 struct scatterlist *sg, unsigned long phys_pfn,17231681 unsigned long nr_pages, int prot)···17541656 phys_addr_t uninitialized_var(pteval);17551657 int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;17561658 unsigned long sg_res;16591659+ unsigned int largepage_lvl = 0;16601660+ unsigned long lvl_pages = 0;1757166117581662 BUG_ON(addr_width < BITS_PER_LONG && (iov_pfn + nr_pages - 1) >> addr_width);17591663···17711671 pteval = ((phys_addr_t)phys_pfn << VTD_PAGE_SHIFT) | prot;17721672 }1773167317741774- while (nr_pages--) {16741674+ while (nr_pages > 0) {17751675 uint64_t tmp;1776167617771677 if (!sg_res) {···17791679 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;17801680 sg->dma_length = sg->length;17811681 pteval = page_to_phys(sg_page(sg)) | prot;16821682+ phys_pfn = pteval >> VTD_PAGE_SHIFT;17821683 }16841684+17831685 if (!pte) {17841784- first_pte = pte = pfn_to_dma_pte(domain, iov_pfn);16861686+ largepage_lvl = hardware_largepage_caps(domain, iov_pfn, phys_pfn, sg_res);16871687+16881688+ first_pte = pte = pfn_to_dma_pte(domain, iov_pfn, largepage_lvl);17851689 if (!pte)17861690 return -ENOMEM;16911691+ /* It is large page*/16921692+ if (largepage_lvl > 1)16931693+ pteval |= DMA_PTE_LARGE_PAGE;16941694+ else16951695+ pteval &= ~(uint64_t)DMA_PTE_LARGE_PAGE;16961696+17871697 }17881698 /* We don't need lock here, nobody else17891699 * touches the iova range···18091699 }18101700 WARN_ON(1);18111701 }17021702+17031703+ lvl_pages = lvl_to_nr_pages(largepage_lvl);17041704+17051705+ BUG_ON(nr_pages < lvl_pages);17061706+ BUG_ON(sg_res < lvl_pages);17071707+17081708+ nr_pages -= lvl_pages;17091709+ iov_pfn += lvl_pages;17101710+ phys_pfn += lvl_pages;17111711+ pteval += lvl_pages * VTD_PAGE_SIZE;17121712+ sg_res -= lvl_pages;17131713+17141714+ /* If the next PTE would be the first in a new page, then we17151715+ need to flush the cache on the entries we've just written.17161716+ And then we'll need to recalculate 'pte', so clear it and17171717+ let it get set again in the if (!pte) block above.17181718+17191719+ If we're done (!nr_pages) we need to flush the cache too.17201720+17211721+ Also if we've been setting superpages, we may need to17221722+ recalculate 'pte' and switch back to smaller pages for the17231723+ end of the mapping, if the trailing size is not enough to17241724+ use another superpage (i.e. sg_res < lvl_pages). */18121725 pte++;18131813- if (!nr_pages || first_pte_in_page(pte)) {17261726+ if (!nr_pages || first_pte_in_page(pte) ||17271727+ (largepage_lvl > 1 && sg_res < lvl_pages)) {18141728 domain_flush_cache(domain, first_pte,18151729 (void *)pte - (void *)first_pte);18161730 pte = NULL;18171731 }18181818- iov_pfn++;18191819- pteval += VTD_PAGE_SIZE;18201820- sg_res--;18211821- if (!sg_res)17321732+17331733+ if (!sg_res && nr_pages)18221734 sg = sg_next(sg);18231735 }18241736 return 0;···21482016 if (pdev->dev.archdata.iommu == DUMMY_DEVICE_DOMAIN_INFO)21492017 return 0;21502018 return iommu_prepare_identity_map(pdev, rmrr->base_address,21512151- rmrr->end_address + 1);20192019+ rmrr->end_address);21522020}2153202121542022#ifdef CONFIG_DMAR_FLOPPY_WA···21622030 return;2163203121642032 printk(KERN_INFO "IOMMU: Prepare 0-16MiB unity mapping for LPC\n");21652165- ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024);20332033+ ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024 - 1);2166203421672035 if (ret)21682036 printk(KERN_ERR "IOMMU: Failed to create 0-16MiB identity map; "···22382106 if (likely(!iommu_identity_mapping))22392107 return 0;2240210821092109+ info = pdev->dev.archdata.iommu;21102110+ if (info && info != DUMMY_DEVICE_DOMAIN_INFO)21112111+ return (info->domain == si_domain);2241211222422242- list_for_each_entry(info, &si_domain->devices, link)22432243- if (info->dev == pdev)22442244- return 1;22452113 return 0;22462114}22472115···23192187 * Assume that they will -- if they turn out not to be, then we can 23202188 * take them out of the 1:1 domain later.23212189 */23222322- if (!startup)23232323- return pdev->dma_mask > DMA_BIT_MASK(32);21902190+ if (!startup) {21912191+ /*21922192+ * If the device's dma_mask is less than the system's memory21932193+ * size then this is not a candidate for identity mapping.21942194+ */21952195+ u64 dma_mask = pdev->dma_mask;21962196+21972197+ if (pdev->dev.coherent_dma_mask &&21982198+ pdev->dev.coherent_dma_mask < dma_mask)21992199+ dma_mask = pdev->dev.coherent_dma_mask;22002200+22012201+ return dma_mask >= dma_get_required_mask(&pdev->dev);22022202+ }2324220323252204 return 1;23262205}···23462203 return -EFAULT;2347220423482205 for_each_pci_dev(pdev) {22062206+ /* Skip Host/PCI Bridge devices */22072207+ if (IS_BRIDGE_HOST_DEVICE(pdev))22082208+ continue;23492209 if (iommu_should_identity_map(pdev, 1)) {23502210 printk(KERN_INFO "IOMMU: %s identity mapping for device %s\n",23512211 hw ? "hardware" : "software", pci_name(pdev));···23642218 return 0;23652219}2366222023672367-static int __init init_dmars(int force_on)22212221+static int __init init_dmars(void)23682222{23692223 struct dmar_drhd_unit *drhd;23702224 struct dmar_rmrr_unit *rmrr;···27382592 iommu = domain_get_iommu(domain);27392593 size = aligned_nrpages(paddr, size);2740259427412741- iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size),27422742- pdev->dma_mask);25952595+ iova = intel_alloc_iova(hwdev, domain, dma_to_mm_pfn(size), dma_mask);27432596 if (!iova)27442597 goto error;27452598···32633118 if (iommu->qi)32643119 dmar_reenable_qi(iommu);3265312032663266- for_each_active_iommu(iommu, drhd) {31213121+ for_each_iommu(iommu, drhd) {31223122+ if (drhd->ignored) {31233123+ /*31243124+ * we always have to disable PMRs or DMA may fail on31253125+ * this device31263126+ */31273127+ if (force_on)31283128+ iommu_disable_protect_mem_regions(iommu);31293129+ continue;31303130+ }31313131+32673132 iommu_flush_write_buffer(iommu);3268313332693134 iommu_set_root_entry(iommu);···32823127 DMA_CCMD_GLOBAL_INVL);32833128 iommu->flush.flush_iotlb(iommu, 0, 0, 0,32843129 DMA_TLB_GLOBAL_FLUSH);32853285- iommu_enable_translation(iommu);31303130+ if (iommu_enable_translation(iommu))31313131+ return 1;32863132 iommu_disable_protect_mem_regions(iommu);32873133 }32883134···33503194 unsigned long flag;3351319533523196 if (init_iommu_hw()) {33533353- WARN(1, "IOMMU setup failed, DMAR can not resume!\n");31973197+ if (force_on)31983198+ panic("tboot: IOMMU setup failed, DMAR can not resume!\n");31993199+ else32003200+ WARN(1, "IOMMU setup failed, DMAR can not resume!\n");33543201 return;33553202 }33563203···34303271int __init intel_iommu_init(void)34313272{34323273 int ret = 0;34333433- int force_on = 0;3434327434353275 /* VT-d is required for a TXT/tboot launch, so enforce that */34363276 force_on = tboot_force_iommu();···3467330934683310 init_no_remapping_devices();3469331134703470- ret = init_dmars(force_on);33123312+ ret = init_dmars();34713313 if (ret) {34723314 if (force_on)34733315 panic("tboot: Failed to initialize DMARs\n");···35383380 spin_lock_irqsave(&device_domain_lock, flags);35393381 list_for_each_safe(entry, tmp, &domain->devices) {35403382 info = list_entry(entry, struct device_domain_info, link);35413541- /* No need to compare PCI domain; it has to be the same */35423542- if (info->bus == pdev->bus->number &&33833383+ if (info->segment == pci_domain_nr(pdev->bus) &&33843384+ info->bus == pdev->bus->number &&35433385 info->devfn == pdev->devfn) {35443386 list_del(&info->link);35453387 list_del(&info->global);···35773419 domain_update_iommu_cap(domain);35783420 spin_unlock_irqrestore(&domain->iommu_lock, tmp_flags);3579342135803580- spin_lock_irqsave(&iommu->lock, tmp_flags);35813581- clear_bit(domain->id, iommu->domain_ids);35823582- iommu->domains[domain->id] = NULL;35833583- spin_unlock_irqrestore(&iommu->lock, tmp_flags);34223422+ if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) &&34233423+ !(domain->flags & DOMAIN_FLAG_STATIC_IDENTITY)) {34243424+ spin_lock_irqsave(&iommu->lock, tmp_flags);34253425+ clear_bit(domain->id, iommu->domain_ids);34263426+ iommu->domains[domain->id] = NULL;34273427+ spin_unlock_irqrestore(&iommu->lock, tmp_flags);34283428+ }35843429 }3585343035863431 spin_unlock_irqrestore(&device_domain_lock, flags);···36663505 domain->iommu_count = 0;36673506 domain->iommu_coherency = 0;36683507 domain->iommu_snooping = 0;35083508+ domain->iommu_superpage = 0;36693509 domain->max_addr = 0;36703510 domain->nid = -1;36713511···38823720 struct dma_pte *pte;38833721 u64 phys = 0;3884372238853885- pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT);37233723+ pte = pfn_to_dma_pte(dmar_domain, iova >> VTD_PAGE_SHIFT, 0);38863724 if (pte)38873725 phys = dma_pte_addr(pte);38883726
+10-2
drivers/pci/iova.c
···6363 curr = iovad->cached32_node;6464 cached_iova = container_of(curr, struct iova, node);65656666- if (free->pfn_lo >= cached_iova->pfn_lo)6767- iovad->cached32_node = rb_next(&free->node);6666+ if (free->pfn_lo >= cached_iova->pfn_lo) {6767+ struct rb_node *node = rb_next(&free->node);6868+ struct iova *iova = container_of(node, struct iova, node);6969+7070+ /* only cache if it's below 32bit pfn */7171+ if (node && iova->pfn_lo < iovad->dma_32bit_pfn)7272+ iovad->cached32_node = node;7373+ else7474+ iovad->cached32_node = NULL;7575+ }6876}69777078/* Computes the padding size required, to make the
···322322 kfree(evt);323323 }324324325325+ blk_put_queue(sdev->request_queue);325326 /* NULL queue means the device can't be used */326327 sdev->request_queue = NULL;327328
···188188 poll_table *wait);189189static int n_hdlc_tty_open(struct tty_struct *tty);190190static void n_hdlc_tty_close(struct tty_struct *tty);191191-static unsigned int n_hdlc_tty_receive(struct tty_struct *tty,192192- const __u8 *cp, char *fp, int count);191191+static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *cp,192192+ char *fp, int count);193193static void n_hdlc_tty_wakeup(struct tty_struct *tty);194194195195#define bset(p,b) ((p)[(b) >> 5] |= (1 << ((b) & 0x1f)))···509509 * Called by tty low level driver when receive data is available. Data is510510 * interpreted as one HDLC frame.511511 */512512-static unsigned int n_hdlc_tty_receive(struct tty_struct *tty,513513- const __u8 *data, char *flags, int count)512512+static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,513513+ char *flags, int count)514514{515515 register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);516516 register struct n_hdlc_buf *buf;···521521522522 /* This can happen if stuff comes in on the backup tty */523523 if (!n_hdlc || tty != n_hdlc->tty)524524- return -ENODEV;524524+ return;525525526526 /* verify line is using HDLC discipline */527527 if (n_hdlc->magic != HDLC_MAGIC) {528528 printk("%s(%d) line not using HDLC discipline\n",529529 __FILE__,__LINE__);530530- return -EINVAL;530530+ return;531531 }532532533533 if ( count>maxframe ) {534534 if (debuglevel >= DEBUG_LEVEL_INFO) 535535 printk("%s(%d) rx count>maxframesize, data discarded\n",536536 __FILE__,__LINE__);537537- return -EINVAL;537537+ return;538538 }539539540540 /* get a free HDLC buffer */ ···550550 if (debuglevel >= DEBUG_LEVEL_INFO) 551551 printk("%s(%d) no more rx buffers, data discarded\n",552552 __FILE__,__LINE__);553553- return -EINVAL;553553+ return;554554 }555555556556 /* copy received data to HDLC buffer */···564564 wake_up_interruptible (&tty->read_wait);565565 if (n_hdlc->tty->fasync != NULL)566566 kill_fasync (&n_hdlc->tty->fasync, SIGIO, POLL_IN);567567-568568- return count;569567570568} /* end of n_hdlc_tty_receive() */571569
···8181 return put_user(x, ptr);8282}83838484+/**8585+ * n_tty_set__room - receive space8686+ * @tty: terminal8787+ *8888+ * Called by the driver to find out how much data it is8989+ * permitted to feed to the line discipline without any being lost9090+ * and thus to manage flow control. Not serialized. Answers for the9191+ * "instant".9292+ */9393+9494+static void n_tty_set_room(struct tty_struct *tty)9595+{9696+ /* tty->read_cnt is not read locked ? */9797+ int left = N_TTY_BUF_SIZE - tty->read_cnt - 1;9898+ int old_left;9999+100100+ /*101101+ * If we are doing input canonicalization, and there are no102102+ * pending newlines, let characters through without limit, so103103+ * that erase characters will be handled. Other excess104104+ * characters will be beeped.105105+ */106106+ if (left <= 0)107107+ left = tty->icanon && !tty->canon_data;108108+ old_left = tty->receive_room;109109+ tty->receive_room = left;110110+111111+ /* Did this open up the receive buffer? We may need to flip */112112+ if (left && !old_left)113113+ schedule_work(&tty->buf.work);114114+}115115+84116static void put_tty_queue_nolock(unsigned char c, struct tty_struct *tty)85117{86118 if (tty->read_cnt < N_TTY_BUF_SIZE) {···184152185153 tty->canon_head = tty->canon_data = tty->erasing = 0;186154 memset(&tty->read_flags, 0, sizeof tty->read_flags);155155+ n_tty_set_room(tty);187156 check_unthrottle(tty);188157}189158···13601327 * calls one at a time and in order (or using flush_to_ldisc)13611328 */1362132913631363-static unsigned int n_tty_receive_buf(struct tty_struct *tty,13641364- const unsigned char *cp, char *fp, int count)13301330+static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,13311331+ char *fp, int count)13651332{13661333 const unsigned char *p;13671334 char *f, flags = TTY_NORMAL;13681335 int i;13691336 char buf[64];13701337 unsigned long cpuflags;13711371- int left;13721372- int ret = 0;1373133813741339 if (!tty->read_buf)13751375- return 0;13401340+ return;1376134113771342 if (tty->real_raw) {13781343 spin_lock_irqsave(&tty->read_lock, cpuflags);···13801349 memcpy(tty->read_buf + tty->read_head, cp, i);13811350 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);13821351 tty->read_cnt += i;13831383- ret += i;13841352 cp += i;13851353 count -= i;13861354···13891359 memcpy(tty->read_buf + tty->read_head, cp, i);13901360 tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);13911361 tty->read_cnt += i;13921392- ret += i;13931362 spin_unlock_irqrestore(&tty->read_lock, cpuflags);13941363 } else {13951395- ret = count;13961364 for (i = count, p = cp, f = fp; i; i--, p++) {13971365 if (f)13981366 flags = *f++;···14181390 tty->ops->flush_chars(tty);14191391 }1420139213931393+ n_tty_set_room(tty);13941394+14211395 if ((!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) ||14221396 L_EXTPROC(tty)) {14231397 kill_fasync(&tty->fasync, SIGIO, POLL_IN);···14321402 * mode. We don't want to throttle the driver if we're in14331403 * canonical mode and don't have a newline yet!14341404 */14351435- left = N_TTY_BUF_SIZE - tty->read_cnt - 1;14361436-14371437- if (left < TTY_THRESHOLD_THROTTLE)14051405+ if (tty->receive_room < TTY_THRESHOLD_THROTTLE)14381406 tty_throttle(tty);14391439-14401440- return ret;14411407}1442140814431409int is_ignored(int sig)···14771451 if (test_bit(TTY_HW_COOK_IN, &tty->flags)) {14781452 tty->raw = 1;14791453 tty->real_raw = 1;14541454+ n_tty_set_room(tty);14801455 return;14811456 }14821457 if (I_ISTRIP(tty) || I_IUCLC(tty) || I_IGNCR(tty) ||···15301503 else15311504 tty->real_raw = 0;15321505 }15061506+ n_tty_set_room(tty);15331507 /* The termios change make the tty ready for I/O */15341508 wake_up_interruptible(&tty->write_wait);15351509 wake_up_interruptible(&tty->read_wait);···18121784 retval = -ERESTARTSYS;18131785 break;18141786 }17871787+ /* FIXME: does n_tty_set_room need locking ? */17881788+ n_tty_set_room(tty);18151789 timeout = schedule_timeout(timeout);18161790 continue;18171791 }···18851855 * longer than TTY_THRESHOLD_UNTHROTTLE in canonical mode,18861856 * we won't get any more characters.18871857 */18881888- if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE)18581858+ if (n_tty_chars_in_buffer(tty) <= TTY_THRESHOLD_UNTHROTTLE) {18591859+ n_tty_set_room(tty);18891860 check_unthrottle(tty);18611861+ }1890186218911863 if (b - buf >= minimum)18921864 break;···19101878 } else if (test_and_clear_bit(TTY_PUSH, &tty->flags))19111879 goto do_it_again;1912188018811881+ n_tty_set_room(tty);19131882 return retval;19141883}19151884
+6-9
drivers/tty/tty_buffer.c
···416416 struct tty_buffer *head, *tail = tty->buf.tail;417417 int seen_tail = 0;418418 while ((head = tty->buf.head) != NULL) {419419- int copied;420419 int count;421420 char *char_buf;422421 unsigned char *flag_buf;···442443 line discipline as we want to empty the queue */443444 if (test_bit(TTY_FLUSHPENDING, &tty->flags))444445 break;446446+ if (!tty->receive_room || seen_tail)447447+ break;448448+ if (count > tty->receive_room)449449+ count = tty->receive_room;445450 char_buf = head->char_buf_ptr + head->read;446451 flag_buf = head->flag_buf_ptr + head->read;452452+ head->read += count;447453 spin_unlock_irqrestore(&tty->buf.lock, flags);448448- copied = disc->ops->receive_buf(tty, char_buf,454454+ disc->ops->receive_buf(tty, char_buf,449455 flag_buf, count);450456 spin_lock_irqsave(&tty->buf.lock, flags);451451-452452- head->read += copied;453453-454454- if (copied == 0 || seen_tail) {455455- schedule_work(&tty->buf.work);456456- break;457457- }458457 }459458 clear_bit(TTY_FLUSHING, &tty->flags);460459 }
···144144 }145145146146 mutex_lock(&vq->mutex);147147- vhost_disable_notify(vq);147147+ vhost_disable_notify(&net->dev, vq);148148149149 if (wmem < sock->sk->sk_sndbuf / 2)150150 tx_poll_stop(net);···166166 set_bit(SOCK_ASYNC_NOSPACE, &sock->flags);167167 break;168168 }169169- if (unlikely(vhost_enable_notify(vq))) {170170- vhost_disable_notify(vq);169169+ if (unlikely(vhost_enable_notify(&net->dev, vq))) {170170+ vhost_disable_notify(&net->dev, vq);171171 continue;172172 }173173 break;···315315 return;316316317317 mutex_lock(&vq->mutex);318318- vhost_disable_notify(vq);318318+ vhost_disable_notify(&net->dev, vq);319319 vhost_hlen = vq->vhost_hlen;320320 sock_hlen = vq->sock_hlen;321321···334334 break;335335 /* OK, now we need to know about added descriptors. */336336 if (!headcount) {337337- if (unlikely(vhost_enable_notify(vq))) {337337+ if (unlikely(vhost_enable_notify(&net->dev, vq))) {338338 /* They have slipped one in as we were339339 * doing that: check again. */340340- vhost_disable_notify(vq);340340+ vhost_disable_notify(&net->dev, vq);341341 continue;342342 }343343 /* Nothing new? Wait for eventfd to tell us
+3-3
drivers/vhost/test.c
···4949 return;50505151 mutex_lock(&vq->mutex);5252- vhost_disable_notify(vq);5252+ vhost_disable_notify(&n->dev, vq);53535454 for (;;) {5555 head = vhost_get_vq_desc(&n->dev, vq, vq->iov,···6161 break;6262 /* Nothing new? Wait for eventfd to tell us they refilled. */6363 if (head == vq->num) {6464- if (unlikely(vhost_enable_notify(vq))) {6565- vhost_disable_notify(vq);6464+ if (unlikely(vhost_enable_notify(&n->dev, vq))) {6565+ vhost_disable_notify(&n->dev, vq);6666 continue;6767 }6868 break;
+104-34
drivers/vhost/vhost.c
···3737 VHOST_MEMORY_F_LOG = 0x1,3838};39394040+#define vhost_used_event(vq) ((u16 __user *)&vq->avail->ring[vq->num])4141+#define vhost_avail_event(vq) ((u16 __user *)&vq->used->ring[vq->num])4242+4043static void vhost_poll_func(struct file *file, wait_queue_head_t *wqh,4144 poll_table *pt)4245{···164161 vq->last_avail_idx = 0;165162 vq->avail_idx = 0;166163 vq->last_used_idx = 0;164164+ vq->signalled_used = 0;165165+ vq->signalled_used_valid = false;167166 vq->used_flags = 0;168167 vq->log_used = false;169168 vq->log_addr = -1ull;···494489 return 1;495490}496491497497-static int vq_access_ok(unsigned int num,492492+static int vq_access_ok(struct vhost_dev *d, unsigned int num,498493 struct vring_desc __user *desc,499494 struct vring_avail __user *avail,500495 struct vring_used __user *used)501496{497497+ size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;502498 return access_ok(VERIFY_READ, desc, num * sizeof *desc) &&503499 access_ok(VERIFY_READ, avail,504504- sizeof *avail + num * sizeof *avail->ring) &&500500+ sizeof *avail + num * sizeof *avail->ring + s) &&505501 access_ok(VERIFY_WRITE, used,506506- sizeof *used + num * sizeof *used->ring);502502+ sizeof *used + num * sizeof *used->ring + s);507503}508504509505/* Can we log writes? */···520514521515/* Verify access for write logging. */522516/* Caller should have vq mutex and device mutex */523523-static int vq_log_access_ok(struct vhost_virtqueue *vq, void __user *log_base)517517+static int vq_log_access_ok(struct vhost_dev *d, struct vhost_virtqueue *vq,518518+ void __user *log_base)524519{525520 struct vhost_memory *mp;521521+ size_t s = vhost_has_feature(d, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0;526522527523 mp = rcu_dereference_protected(vq->dev->memory,528524 lockdep_is_held(&vq->mutex));···532524 vhost_has_feature(vq->dev, VHOST_F_LOG_ALL)) &&533525 (!vq->log_used || log_access_ok(log_base, vq->log_addr,534526 sizeof *vq->used +535535- vq->num * sizeof *vq->used->ring));527527+ vq->num * sizeof *vq->used->ring + s));536528}537529538530/* Can we start vq? */539531/* Caller should have vq mutex and device mutex */540532int vhost_vq_access_ok(struct vhost_virtqueue *vq)541533{542542- return vq_access_ok(vq->num, vq->desc, vq->avail, vq->used) &&543543- vq_log_access_ok(vq, vq->log_base);534534+ return vq_access_ok(vq->dev, vq->num, vq->desc, vq->avail, vq->used) &&535535+ vq_log_access_ok(vq->dev, vq, vq->log_base);544536}545537546538static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)···585577586578 if (r)587579 return r;580580+ vq->signalled_used_valid = false;588581 return get_user(vq->last_used_idx, &used->idx);589582}590583···683674 * If it is not, we don't as size might not have been setup.684675 * We will verify when backend is configured. */685676 if (vq->private_data) {686686- if (!vq_access_ok(vq->num,677677+ if (!vq_access_ok(d, vq->num,687678 (void __user *)(unsigned long)a.desc_user_addr,688679 (void __user *)(unsigned long)a.avail_user_addr,689680 (void __user *)(unsigned long)a.used_user_addr)) {···827818 vq = d->vqs + i;828819 mutex_lock(&vq->mutex);829820 /* If ring is inactive, will check when it's enabled. */830830- if (vq->private_data && !vq_log_access_ok(vq, base))821821+ if (vq->private_data && !vq_log_access_ok(d, vq, base))831822 r = -EFAULT;832823 else833824 vq->log_base = base;···1228121912291220 /* On success, increment avail index. */12301221 vq->last_avail_idx++;12221222+12231223+ /* Assume notifications from guest are disabled at this point,12241224+ * if they aren't we would need to update avail_event index. */12251225+ BUG_ON(!(vq->used_flags & VRING_USED_F_NO_NOTIFY));12311226 return head;12321227}12331228···12801267 eventfd_signal(vq->log_ctx, 1);12811268 }12821269 vq->last_used_idx++;12701270+ /* If the driver never bothers to signal in a very long while,12711271+ * used index might wrap around. If that happens, invalidate12721272+ * signalled_used index we stored. TODO: make sure driver12731273+ * signals at least once in 2^16 and remove this. */12741274+ if (unlikely(vq->last_used_idx == vq->signalled_used))12751275+ vq->signalled_used_valid = false;12831276 return 0;12841277}12851278···12941275 unsigned count)12951276{12961277 struct vring_used_elem __user *used;12781278+ u16 old, new;12971279 int start;1298128012991281 start = vq->last_used_idx % vq->num;···13121292 ((void __user *)used - (void __user *)vq->used),13131293 count * sizeof *used);13141294 }13151315- vq->last_used_idx += count;12951295+ old = vq->last_used_idx;12961296+ new = (vq->last_used_idx += count);12971297+ /* If the driver never bothers to signal in a very long while,12981298+ * used index might wrap around. If that happens, invalidate12991299+ * signalled_used index we stored. TODO: make sure driver13001300+ * signals at least once in 2^16 and remove this. */13011301+ if (unlikely((u16)(new - vq->signalled_used) < (u16)(new - old)))13021302+ vq->signalled_used_valid = false;13161303 return 0;13171304}13181305···13581331 return r;13591332}1360133313611361-/* This actually signals the guest, using eventfd. */13621362-void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)13341334+static bool vhost_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)13631335{13641364- __u16 flags;13651365-13361336+ __u16 old, new, event;13371337+ bool v;13661338 /* Flush out used index updates. This is paired13671339 * with the barrier that the Guest executes when enabling13681340 * interrupts. */13691341 smp_mb();1370134213711371- if (__get_user(flags, &vq->avail->flags)) {13721372- vq_err(vq, "Failed to get flags");13731373- return;13431343+ if (vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY) &&13441344+ unlikely(vq->avail_idx == vq->last_avail_idx))13451345+ return true;13461346+13471347+ if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {13481348+ __u16 flags;13491349+ if (__get_user(flags, &vq->avail->flags)) {13501350+ vq_err(vq, "Failed to get flags");13511351+ return true;13521352+ }13531353+ return !(flags & VRING_AVAIL_F_NO_INTERRUPT);13741354 }13551355+ old = vq->signalled_used;13561356+ v = vq->signalled_used_valid;13571357+ new = vq->signalled_used = vq->last_used_idx;13581358+ vq->signalled_used_valid = true;1375135913761376- /* If they don't want an interrupt, don't signal, unless empty. */13771377- if ((flags & VRING_AVAIL_F_NO_INTERRUPT) &&13781378- (vq->avail_idx != vq->last_avail_idx ||13791379- !vhost_has_feature(dev, VIRTIO_F_NOTIFY_ON_EMPTY)))13801380- return;13601360+ if (unlikely(!v))13611361+ return true;1381136213631363+ if (get_user(event, vhost_used_event(vq))) {13641364+ vq_err(vq, "Failed to get used event idx");13651365+ return true;13661366+ }13671367+ return vring_need_event(event, new, old);13681368+}13691369+13701370+/* This actually signals the guest, using eventfd. */13711371+void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)13721372+{13821373 /* Signal the Guest tell them we used something up. */13831383- if (vq->call_ctx)13741374+ if (vq->call_ctx && vhost_notify(dev, vq))13841375 eventfd_signal(vq->call_ctx, 1);13851376}13861377···14211376}1422137714231378/* OK, now we need to know about added descriptors. */14241424-bool vhost_enable_notify(struct vhost_virtqueue *vq)13791379+bool vhost_enable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)14251380{14261381 u16 avail_idx;14271382 int r;···14291384 if (!(vq->used_flags & VRING_USED_F_NO_NOTIFY))14301385 return false;14311386 vq->used_flags &= ~VRING_USED_F_NO_NOTIFY;14321432- r = put_user(vq->used_flags, &vq->used->flags);14331433- if (r) {14341434- vq_err(vq, "Failed to enable notification at %p: %d\n",14351435- &vq->used->flags, r);14361436- return false;13871387+ if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {13881388+ r = put_user(vq->used_flags, &vq->used->flags);13891389+ if (r) {13901390+ vq_err(vq, "Failed to enable notification at %p: %d\n",13911391+ &vq->used->flags, r);13921392+ return false;13931393+ }13941394+ } else {13951395+ r = put_user(vq->avail_idx, vhost_avail_event(vq));13961396+ if (r) {13971397+ vq_err(vq, "Failed to update avail event index at %p: %d\n",13981398+ vhost_avail_event(vq), r);13991399+ return false;14001400+ }14011401+ }14021402+ if (unlikely(vq->log_used)) {14031403+ void __user *used;14041404+ /* Make sure data is seen before log. */14051405+ smp_wmb();14061406+ used = vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX) ?14071407+ &vq->used->flags : vhost_avail_event(vq);14081408+ /* Log used flags or event index entry write. Both are 16 bit14091409+ * fields. */14101410+ log_write(vq->log_base, vq->log_addr +14111411+ (used - (void __user *)vq->used),14121412+ sizeof(u16));14131413+ if (vq->log_ctx)14141414+ eventfd_signal(vq->log_ctx, 1);14371415 }14381416 /* They could have slipped one in as we were doing that: make14391417 * sure it's written, then check again. */···14721404}1473140514741406/* We don't need to be notified again. */14751475-void vhost_disable_notify(struct vhost_virtqueue *vq)14071407+void vhost_disable_notify(struct vhost_dev *dev, struct vhost_virtqueue *vq)14761408{14771409 int r;1478141014791411 if (vq->used_flags & VRING_USED_F_NO_NOTIFY)14801412 return;14811413 vq->used_flags |= VRING_USED_F_NO_NOTIFY;14821482- r = put_user(vq->used_flags, &vq->used->flags);14831483- if (r)14841484- vq_err(vq, "Failed to enable notification at %p: %d\n",14851485- &vq->used->flags, r);14141414+ if (!vhost_has_feature(dev, VIRTIO_RING_F_EVENT_IDX)) {14151415+ r = put_user(vq->used_flags, &vq->used->flags);14161416+ if (r)14171417+ vq_err(vq, "Failed to enable notification at %p: %d\n",14181418+ &vq->used->flags, r);14191419+ }14861420}
+14-7
drivers/vhost/vhost.h
···8484 /* Used flags */8585 u16 used_flags;86868787+ /* Last used index value we have signalled on */8888+ u16 signalled_used;8989+9090+ /* Last used index value we have signalled on */9191+ bool signalled_used_valid;9292+8793 /* Log writes to used structure. */8894 bool log_used;8995 u64 log_addr;···155149void vhost_add_used_and_signal_n(struct vhost_dev *, struct vhost_virtqueue *,156150 struct vring_used_elem *heads, unsigned count);157151void vhost_signal(struct vhost_dev *, struct vhost_virtqueue *);158158-void vhost_disable_notify(struct vhost_virtqueue *);159159-bool vhost_enable_notify(struct vhost_virtqueue *);152152+void vhost_disable_notify(struct vhost_dev *, struct vhost_virtqueue *);153153+bool vhost_enable_notify(struct vhost_dev *, struct vhost_virtqueue *);160154161155int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log,162156 unsigned int log_num, u64 len);···168162 } while (0)169163170164enum {171171- VHOST_FEATURES = (1 << VIRTIO_F_NOTIFY_ON_EMPTY) |172172- (1 << VIRTIO_RING_F_INDIRECT_DESC) |173173- (1 << VHOST_F_LOG_ALL) |174174- (1 << VHOST_NET_F_VIRTIO_NET_HDR) |175175- (1 << VIRTIO_NET_F_MRG_RXBUF),165165+ VHOST_FEATURES = (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) |166166+ (1ULL << VIRTIO_RING_F_INDIRECT_DESC) |167167+ (1ULL << VIRTIO_RING_F_EVENT_IDX) |168168+ (1ULL << VHOST_F_LOG_ALL) |169169+ (1ULL << VHOST_NET_F_VIRTIO_NET_HDR) |170170+ (1ULL << VIRTIO_NET_F_MRG_RXBUF),176171};177172178173static inline int vhost_has_feature(struct vhost_dev *dev, int bit)
+8-13
drivers/virtio/virtio_balloon.c
···4040 /* Waiting for host to ack the pages we released. */4141 struct completion acked;42424343- /* Do we have to tell Host *before* we reuse pages? */4444- bool tell_host_first;4545-4643 /* The pages we've told the Host we're not using. */4744 unsigned int num_pages;4845 struct list_head pages;···148151 vb->num_pages--;149152 }150153151151- if (vb->tell_host_first) {152152- tell_host(vb, vb->deflate_vq);153153- release_pages_by_pfn(vb->pfns, vb->num_pfns);154154- } else {155155- release_pages_by_pfn(vb->pfns, vb->num_pfns);156156- tell_host(vb, vb->deflate_vq);157157- }154154+155155+ /*156156+ * Note that if157157+ * virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);158158+ * is true, we *have* to do it in this order159159+ */160160+ tell_host(vb, vb->deflate_vq);161161+ release_pages_by_pfn(vb->pfns, vb->num_pfns);158162}159163160164static inline void update_stat(struct virtio_balloon *vb, int idx,···322324 err = PTR_ERR(vb->thread);323325 goto out_del_vqs;324326 }325325-326326- vb->tell_host_first327327- = virtio_has_feature(vdev, VIRTIO_BALLOON_F_MUST_TELL_HOST);328327329328 return 0;330329
+51-2
drivers/virtio/virtio_ring.c
···8282 /* Host supports indirect buffers */8383 bool indirect;84848585+ /* Host publishes avail event idx */8686+ bool event;8787+8588 /* Number of free buffers */8689 unsigned int num_free;8790 /* Head of free buffer list. */···240237void virtqueue_kick(struct virtqueue *_vq)241238{242239 struct vring_virtqueue *vq = to_vvq(_vq);240240+ u16 new, old;243241 START_USE(vq);244242 /* Descriptors and available array need to be set before we expose the245243 * new available array entries. */246244 virtio_wmb();247245248248- vq->vring.avail->idx += vq->num_added;246246+ old = vq->vring.avail->idx;247247+ new = vq->vring.avail->idx = old + vq->num_added;249248 vq->num_added = 0;250249251250 /* Need to update avail index before checking if we should notify */252251 virtio_mb();253252254254- if (!(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))253253+ if (vq->event ?254254+ vring_need_event(vring_avail_event(&vq->vring), new, old) :255255+ !(vq->vring.used->flags & VRING_USED_F_NO_NOTIFY))255256 /* Prod other side to tell it about changes. */256257 vq->notify(&vq->vq);257258···331324 ret = vq->data[i];332325 detach_buf(vq, i);333326 vq->last_used_idx++;327327+ /* If we expect an interrupt for the next entry, tell host328328+ * by writing event index and flush out the write before329329+ * the read in the next get_buf call. */330330+ if (!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) {331331+ vring_used_event(&vq->vring) = vq->last_used_idx;332332+ virtio_mb();333333+ }334334+334335 END_USE(vq);335336 return ret;336337}···360345361346 /* We optimistically turn back on interrupts, then check if there was362347 * more to do. */348348+ /* Depending on the VIRTIO_RING_F_EVENT_IDX feature, we need to349349+ * either clear the flags bit or point the event index at the next350350+ * entry. Always do both to keep code simple. */363351 vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;352352+ vring_used_event(&vq->vring) = vq->last_used_idx;364353 virtio_mb();365354 if (unlikely(more_used(vq))) {366355 END_USE(vq);···375356 return true;376357}377358EXPORT_SYMBOL_GPL(virtqueue_enable_cb);359359+360360+bool virtqueue_enable_cb_delayed(struct virtqueue *_vq)361361+{362362+ struct vring_virtqueue *vq = to_vvq(_vq);363363+ u16 bufs;364364+365365+ START_USE(vq);366366+367367+ /* We optimistically turn back on interrupts, then check if there was368368+ * more to do. */369369+ /* Depending on the VIRTIO_RING_F_USED_EVENT_IDX feature, we need to370370+ * either clear the flags bit or point the event index at the next371371+ * entry. Always do both to keep code simple. */372372+ vq->vring.avail->flags &= ~VRING_AVAIL_F_NO_INTERRUPT;373373+ /* TODO: tune this threshold */374374+ bufs = (u16)(vq->vring.avail->idx - vq->last_used_idx) * 3 / 4;375375+ vring_used_event(&vq->vring) = vq->last_used_idx + bufs;376376+ virtio_mb();377377+ if (unlikely((u16)(vq->vring.used->idx - vq->last_used_idx) > bufs)) {378378+ END_USE(vq);379379+ return false;380380+ }381381+382382+ END_USE(vq);383383+ return true;384384+}385385+EXPORT_SYMBOL_GPL(virtqueue_enable_cb_delayed);378386379387void *virtqueue_detach_unused_buf(struct virtqueue *_vq)380388{···484438#endif485439486440 vq->indirect = virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC);441441+ vq->event = virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX);487442488443 /* No callback? Tell other side not to bother us. */489444 if (!callback)···518471 for (i = VIRTIO_TRANSPORT_F_START; i < VIRTIO_TRANSPORT_F_END; i++) {519472 switch (i) {520473 case VIRTIO_RING_F_INDIRECT_DESC:474474+ break;475475+ case VIRTIO_RING_F_EVENT_IDX:521476 break;522477 default:523478 /* We don't understand this bit. */
-2
fs/autofs4/root.c
···583583 if (!autofs4_oz_mode(sbi) && !capable(CAP_SYS_ADMIN))584584 return -EACCES;585585586586- dentry_unhash(dentry);587587-588586 if (atomic_dec_and_test(&ino->count)) {589587 p_ino = autofs4_dentry_ino(dentry->d_parent);590588 if (p_ino && dentry->d_parent != dentry)
+2-2
fs/block_dev.c
···12721272 * individual writeable reference is too fragile given the12731273 * way @mode is used in blkdev_get/put().12741274 */12751275- if ((disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE) &&12761276- !res && (mode & FMODE_WRITE) && !bdev->bd_write_holder) {12751275+ if (!res && (mode & FMODE_WRITE) && !bdev->bd_write_holder &&12761276+ (disk->flags & GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE)) {12771277 bdev->bd_write_holder = true;12781278 disk_block_events(disk);12791279 }
-3
fs/btrfs/btrfs_inode.h
···121121 */122122 u64 index_cnt;123123124124- /* the start of block group preferred for allocations. */125125- u64 block_group;126126-127124 /* the fsync log has some corner cases that mean we have to check128125 * directories to see if any unlinks have been done before129126 * the directory was logged. See tree-log.c for all the
···930930 * is required instead of the faster short fsync log commits931931 */932932 u64 last_trans_log_full_commit;933933- u64 open_ioctl_trans;934933 unsigned long mount_opt:20;935934 unsigned long compress_type:4;936935 u64 max_inline;···946947 struct super_block *sb;947948 struct inode *btree_inode;948949 struct backing_dev_info bdi;949949- struct mutex trans_mutex;950950 struct mutex tree_log_mutex;951951 struct mutex transaction_kthread_mutex;952952 struct mutex cleaner_mutex;···966968 struct rw_semaphore subvol_sem;967969 struct srcu_struct subvol_srcu;968970971971+ spinlock_t trans_lock;969972 struct list_head trans_list;970973 struct list_head hashers;971974 struct list_head dead_roots;···979980 atomic_t async_submit_draining;980981 atomic_t nr_async_bios;981982 atomic_t async_delalloc_pages;983983+ atomic_t open_ioctl_trans;982984983985 /*984986 * this is used by the balancing code to wait for all the pending···10441044 int closing;10451045 int log_root_recovering;10461046 int enospc_unlink;10471047+ int trans_no_join;1047104810481049 u64 total_pinned;10491050···10661065 struct reloc_control *reloc_ctl;1067106610681067 spinlock_t delalloc_lock;10691069- spinlock_t new_trans_lock;10701068 u64 delalloc_bytes;1071106910721070 /* data_alloc_cluster is only used in ssd mode */···13401340#define BTRFS_MOUNT_USER_SUBVOL_RM_ALLOWED (1 << 14)13411341#define BTRFS_MOUNT_ENOSPC_DEBUG (1 << 15)13421342#define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)13431343+#define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)1343134413441345#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)13451346#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)···22392238void btrfs_block_rsv_release(struct btrfs_root *root,22402239 struct btrfs_block_rsv *block_rsv,22412240 u64 num_bytes);22412241+int btrfs_truncate_reserve_metadata(struct btrfs_trans_handle *trans,22422242+ struct btrfs_root *root,22432243+ struct btrfs_block_rsv *rsv);22422244int btrfs_set_block_group_ro(struct btrfs_root *root,22432245 struct btrfs_block_group_cache *cache);22442246int btrfs_set_block_group_rw(struct btrfs_root *root,···23542350 struct btrfs_root *root,23552351 struct extent_buffer *node,23562352 struct extent_buffer *parent);23532353+static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)23542354+{23552355+ /*23562356+ * Get synced with close_ctree()23572357+ */23582358+ smp_mb();23592359+ return fs_info->closing;23602360+}23612361+23572362/* root-item.c */23582363int btrfs_find_root_ref(struct btrfs_root *tree_root,23592364 struct btrfs_path *path,···25252512int btrfs_writepages(struct address_space *mapping,25262513 struct writeback_control *wbc);25272514int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,25282528- struct btrfs_root *new_root,25292529- u64 new_dirid, u64 alloc_hint);25152515+ struct btrfs_root *new_root, u64 new_dirid);25302516int btrfs_merge_bio_hook(struct page *page, unsigned long offset,25312517 size_t size, struct bio *bio, unsigned long bio_flags);25322518
+4-4
fs/btrfs/delayed-inode.c
···678678 INIT_LIST_HEAD(&head);679679680680 next = item;681681+ nitems = 0;681682682683 /*683684 * count the number of the continuous items that we can insert in batch···11301129 delayed_node = async_node->delayed_node;11311130 root = delayed_node->root;1132113111331133- trans = btrfs_join_transaction(root, 0);11321132+ trans = btrfs_join_transaction(root);11341133 if (IS_ERR(trans))11351134 goto free_path;11361135···15731572 btrfs_set_stack_inode_transid(inode_item, trans->transid);15741573 btrfs_set_stack_inode_rdev(inode_item, inode->i_rdev);15751574 btrfs_set_stack_inode_flags(inode_item, BTRFS_I(inode)->flags);15761576- btrfs_set_stack_inode_block_group(inode_item,15771577- BTRFS_I(inode)->block_group);15751575+ btrfs_set_stack_inode_block_group(inode_item, 0);1578157615791577 btrfs_set_stack_timespec_sec(btrfs_inode_atime(inode_item),15801578 inode->i_atime.tv_sec);···15951595 struct btrfs_root *root, struct inode *inode)15961596{15971597 struct btrfs_delayed_node *delayed_node;15981598- int ret;15981598+ int ret = 0;1599159916001600 delayed_node = btrfs_get_or_create_delayed_node(inode);16011601 if (IS_ERR(delayed_node))
+18-18
fs/btrfs/disk-io.c
···15051505 vfs_check_frozen(root->fs_info->sb, SB_FREEZE_WRITE);15061506 mutex_lock(&root->fs_info->transaction_kthread_mutex);1507150715081508- spin_lock(&root->fs_info->new_trans_lock);15081508+ spin_lock(&root->fs_info->trans_lock);15091509 cur = root->fs_info->running_transaction;15101510 if (!cur) {15111511- spin_unlock(&root->fs_info->new_trans_lock);15111511+ spin_unlock(&root->fs_info->trans_lock);15121512 goto sleep;15131513 }1514151415151515 now = get_seconds();15161516 if (!cur->blocked &&15171517 (now < cur->start_time || now - cur->start_time < 30)) {15181518- spin_unlock(&root->fs_info->new_trans_lock);15181518+ spin_unlock(&root->fs_info->trans_lock);15191519 delay = HZ * 5;15201520 goto sleep;15211521 }15221522 transid = cur->transid;15231523- spin_unlock(&root->fs_info->new_trans_lock);15231523+ spin_unlock(&root->fs_info->trans_lock);1524152415251525- trans = btrfs_join_transaction(root, 1);15251525+ trans = btrfs_join_transaction(root);15261526 BUG_ON(IS_ERR(trans));15271527 if (transid == trans->transid) {15281528 ret = btrfs_commit_transaction(trans, root);···16131613 INIT_LIST_HEAD(&fs_info->ordered_operations);16141614 INIT_LIST_HEAD(&fs_info->caching_block_groups);16151615 spin_lock_init(&fs_info->delalloc_lock);16161616- spin_lock_init(&fs_info->new_trans_lock);16161616+ spin_lock_init(&fs_info->trans_lock);16171617 spin_lock_init(&fs_info->ref_cache_lock);16181618 spin_lock_init(&fs_info->fs_roots_radix_lock);16191619 spin_lock_init(&fs_info->delayed_iput_lock);···16451645 fs_info->max_inline = 8192 * 1024;16461646 fs_info->metadata_ratio = 0;16471647 fs_info->defrag_inodes = RB_ROOT;16481648+ fs_info->trans_no_join = 0;1648164916491650 fs_info->thread_pool_size = min_t(unsigned long,16501651 num_online_cpus() + 2, 8);···17101709 fs_info->do_barriers = 1;171117101712171117131713- mutex_init(&fs_info->trans_mutex);17141712 mutex_init(&fs_info->ordered_operations_mutex);17151713 mutex_init(&fs_info->tree_log_mutex);17161714 mutex_init(&fs_info->chunk_mutex);···24792479 down_write(&root->fs_info->cleanup_work_sem);24802480 up_write(&root->fs_info->cleanup_work_sem);2481248124822482- trans = btrfs_join_transaction(root, 1);24822482+ trans = btrfs_join_transaction(root);24832483 if (IS_ERR(trans))24842484 return PTR_ERR(trans);24852485 ret = btrfs_commit_transaction(trans, root);24862486 BUG_ON(ret);24872487 /* run commit again to drop the original snapshot */24882488- trans = btrfs_join_transaction(root, 1);24882488+ trans = btrfs_join_transaction(root);24892489 if (IS_ERR(trans))24902490 return PTR_ERR(trans);24912491 btrfs_commit_transaction(trans, root);···3024302430253025 WARN_ON(1);3026302630273027- mutex_lock(&root->fs_info->trans_mutex);30283027 mutex_lock(&root->fs_info->transaction_kthread_mutex);3029302830293029+ spin_lock(&root->fs_info->trans_lock);30303030 list_splice_init(&root->fs_info->trans_list, &list);30313031+ root->fs_info->trans_no_join = 1;30323032+ spin_unlock(&root->fs_info->trans_lock);30333033+30313034 while (!list_empty(&list)) {30323035 t = list_entry(list.next, struct btrfs_transaction, list);30333036 if (!t)···30553052 t->blocked = 0;30563053 if (waitqueue_active(&root->fs_info->transaction_wait))30573054 wake_up(&root->fs_info->transaction_wait);30583058- mutex_unlock(&root->fs_info->trans_mutex);3059305530603060- mutex_lock(&root->fs_info->trans_mutex);30613056 t->commit_done = 1;30623057 if (waitqueue_active(&t->commit_wait))30633058 wake_up(&t->commit_wait);30643064- mutex_unlock(&root->fs_info->trans_mutex);30653065-30663066- mutex_lock(&root->fs_info->trans_mutex);3067305930683060 btrfs_destroy_pending_snapshots(t);3069306130703062 btrfs_destroy_delalloc_inodes(root);3071306330723072- spin_lock(&root->fs_info->new_trans_lock);30643064+ spin_lock(&root->fs_info->trans_lock);30733065 root->fs_info->running_transaction = NULL;30743074- spin_unlock(&root->fs_info->new_trans_lock);30663066+ spin_unlock(&root->fs_info->trans_lock);3075306730763068 btrfs_destroy_marked_extents(root, &t->dirty_pages,30773069 EXTENT_DIRTY);···30803082 kmem_cache_free(btrfs_transaction_cachep, t);30813083 }3082308430853085+ spin_lock(&root->fs_info->trans_lock);30863086+ root->fs_info->trans_no_join = 0;30873087+ spin_unlock(&root->fs_info->trans_lock);30833088 mutex_unlock(&root->fs_info->transaction_kthread_mutex);30843084- mutex_unlock(&root->fs_info->trans_mutex);3085308930863090 return 0;30873091}
+68-35
fs/btrfs/extent-tree.c
···348348 */349349 path->skip_locking = 1;350350 path->search_commit_root = 1;351351- path->reada = 2;351351+ path->reada = 1;352352353353 key.objectid = last;354354 key.offset = 0;···366366 nritems = btrfs_header_nritems(leaf);367367368368 while (1) {369369- smp_mb();370370- if (fs_info->closing > 1) {369369+ if (btrfs_fs_closing(fs_info) > 1) {371370 last = (u64)-1;372371 break;373372 }···378379 if (ret)379380 break;380381381381- caching_ctl->progress = last;382382- btrfs_release_path(path);383383- up_read(&fs_info->extent_commit_sem);384384- mutex_unlock(&caching_ctl->mutex);385385- if (btrfs_transaction_in_commit(fs_info))386386- schedule_timeout(1);387387- else382382+ if (need_resched() ||383383+ btrfs_next_leaf(extent_root, path)) {384384+ caching_ctl->progress = last;385385+ btrfs_release_path(path);386386+ up_read(&fs_info->extent_commit_sem);387387+ mutex_unlock(&caching_ctl->mutex);388388 cond_resched();389389- goto again;389389+ goto again;390390+ }391391+ leaf = path->nodes[0];392392+ nritems = btrfs_header_nritems(leaf);393393+ continue;390394 }391395392396 if (key.objectid < block_group->key.objectid) {···30673065 spin_unlock(&data_sinfo->lock);30683066alloc:30693067 alloc_target = btrfs_get_alloc_profile(root, 1);30703070- trans = btrfs_join_transaction(root, 1);30683068+ trans = btrfs_join_transaction(root);30713069 if (IS_ERR(trans))30723070 return PTR_ERR(trans);30733071···3093309130943092 /* commit the current transaction and try again */30953093commit_trans:30963096- if (!committed && !root->fs_info->open_ioctl_trans) {30943094+ if (!committed &&30953095+ !atomic_read(&root->fs_info->open_ioctl_trans)) {30973096 committed = 1;30983098- trans = btrfs_join_transaction(root, 1);30973097+ trans = btrfs_join_transaction(root);30993098 if (IS_ERR(trans))31003099 return PTR_ERR(trans);31013100 ret = btrfs_commit_transaction(trans, root);···34753472 goto out;3476347334773474 ret = -ENOSPC;34783478- trans = btrfs_join_transaction(root, 1);34753475+ trans = btrfs_join_transaction(root);34793476 if (IS_ERR(trans))34803477 goto out;34813478 ret = btrfs_commit_transaction(trans, root);···37023699 if (trans)37033700 return -EAGAIN;3704370137053705- trans = btrfs_join_transaction(root, 1);37023702+ trans = btrfs_join_transaction(root);37063703 BUG_ON(IS_ERR(trans));37073704 ret = btrfs_commit_transaction(trans, root);37083705 return 0;···38403837 WARN_ON(fs_info->chunk_block_rsv.reserved > 0);38413838}3842383938403840+int btrfs_truncate_reserve_metadata(struct btrfs_trans_handle *trans,38413841+ struct btrfs_root *root,38423842+ struct btrfs_block_rsv *rsv)38433843+{38443844+ struct btrfs_block_rsv *trans_rsv = &root->fs_info->trans_block_rsv;38453845+ u64 num_bytes;38463846+ int ret;38473847+38483848+ /*38493849+ * Truncate should be freeing data, but give us 2 items just in case it38503850+ * needs to use some space. We may want to be smarter about this in the38513851+ * future.38523852+ */38533853+ num_bytes = btrfs_calc_trans_metadata_size(root, 2);38543854+38553855+ /* We already have enough bytes, just return */38563856+ if (rsv->reserved >= num_bytes)38573857+ return 0;38583858+38593859+ num_bytes -= rsv->reserved;38603860+38613861+ /*38623862+ * You should have reserved enough space before hand to do this, so this38633863+ * should not fail.38643864+ */38653865+ ret = block_rsv_migrate_bytes(trans_rsv, rsv, num_bytes);38663866+ BUG_ON(ret);38673867+38683868+ return 0;38693869+}38703870+38433871int btrfs_trans_reserve_metadata(struct btrfs_trans_handle *trans,38443872 struct btrfs_root *root,38453873 int num_items)···39113877 struct btrfs_block_rsv *dst_rsv = root->orphan_block_rsv;3912387839133879 /*39143914- * one for deleting orphan item, one for updating inode and39153915- * two for calling btrfs_truncate_inode_items.39163916- *39173917- * btrfs_truncate_inode_items is a delete operation, it frees39183918- * more space than it uses in most cases. So two units of39193919- * metadata space should be enough for calling it many times.39203920- * If all of the metadata space is used, we can commit39213921- * transaction and use space it freed.38803880+ * We need to hold space in order to delete our orphan item once we've38813881+ * added it, so this takes the reservation so we can release it later38823882+ * when we are truly done with the orphan item.39223883 */39233923- u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4);38843884+ u64 num_bytes = btrfs_calc_trans_metadata_size(root, 1);39243885 return block_rsv_migrate_bytes(src_rsv, dst_rsv, num_bytes);39253886}3926388739273888void btrfs_orphan_release_metadata(struct inode *inode)39283889{39293890 struct btrfs_root *root = BTRFS_I(inode)->root;39303930- u64 num_bytes = btrfs_calc_trans_metadata_size(root, 4);38913891+ u64 num_bytes = btrfs_calc_trans_metadata_size(root, 1);39313892 btrfs_block_rsv_release(root, root->orphan_block_rsv, num_bytes);39323893}39333894···50164987 if (unlikely(block_group->ro))50174988 goto loop;5018498949904990+ spin_lock(&block_group->free_space_ctl->tree_lock);49914991+ if (cached &&49924992+ block_group->free_space_ctl->free_space <49934993+ num_bytes + empty_size) {49944994+ spin_unlock(&block_group->free_space_ctl->tree_lock);49954995+ goto loop;49964996+ }49974997+ spin_unlock(&block_group->free_space_ctl->tree_lock);49984998+50194999 /*50205000 * Ok we want to try and use the cluster allocator, so lets look50215001 * there, unless we are on LOOP_NO_EMPTY_SIZE, since we will···51885150 btrfs_add_free_space(block_group, offset,51895151 search_start - offset);51905152 BUG_ON(offset > search_start);51535153+ btrfs_put_block_group(block_group);51915154 break;51925155loop:51935156 failed_cluster_refill = false;···52815242 ret = -ENOSPC;52825243 } else if (!ins->objectid) {52835244 ret = -ENOSPC;52845284- }52855285-52865286- /* we found what we needed */52875287- if (ins->objectid) {52885288- if (!(data & BTRFS_BLOCK_GROUP_DATA))52895289- trans->block_group = block_group->key.objectid;52905290-52915291- btrfs_put_block_group(block_group);52455245+ } else if (ins->objectid) {52925246 ret = 0;52935247 }52945248···6558652665596527 BUG_ON(cache->ro);6560652865616561- trans = btrfs_join_transaction(root, 1);65296529+ trans = btrfs_join_transaction(root);65626530 BUG_ON(IS_ERR(trans));6563653165646532 alloc_flags = update_block_group_flags(root, cache->flags);···69146882 path = btrfs_alloc_path();69156883 if (!path)69166884 return -ENOMEM;68856885+ path->reada = 1;6917688669186887 cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy);69196888 if (cache_gen != 0 &&
···129129 if (!btrfs_test_opt(root, AUTO_DEFRAG))130130 return 0;131131132132- if (root->fs_info->closing)132132+ if (btrfs_fs_closing(root->fs_info))133133 return 0;134134135135 if (BTRFS_I(inode)->in_defrag)···144144 if (!defrag)145145 return -ENOMEM;146146147147- defrag->ino = inode->i_ino;147147+ defrag->ino = btrfs_ino(inode);148148 defrag->transid = transid;149149 defrag->root = root->root_key.objectid;150150···229229 first_ino = defrag->ino + 1;230230 rb_erase(&defrag->rb_node, &fs_info->defrag_inodes);231231232232- if (fs_info->closing)232232+ if (btrfs_fs_closing(fs_info))233233 goto next_free;234234235235 spin_unlock(&fs_info->defrag_inodes_lock);···14801480 * the current transaction, we can bail out now without any14811481 * syncing14821482 */14831483- mutex_lock(&root->fs_info->trans_mutex);14831483+ smp_mb();14841484 if (BTRFS_I(inode)->last_trans <=14851485 root->fs_info->last_trans_committed) {14861486 BTRFS_I(inode)->last_trans = 0;14871487- mutex_unlock(&root->fs_info->trans_mutex);14881487 goto out;14891488 }14901490- mutex_unlock(&root->fs_info->trans_mutex);1491148914921490 /*14931491 * ok we haven't committed the transaction yet, lets do a commit
+53-17
fs/btrfs/free-space-cache.c
···9898 return inode;9999100100 spin_lock(&block_group->lock);101101- if (!root->fs_info->closing) {101101+ if (!btrfs_fs_closing(root->fs_info)) {102102 block_group->inode = igrab(inode);103103 block_group->iref = 1;104104 }···402402 spin_lock(&ctl->tree_lock);403403 ret = link_free_space(ctl, e);404404 spin_unlock(&ctl->tree_lock);405405- BUG_ON(ret);405405+ if (ret) {406406+ printk(KERN_ERR "Duplicate entries in "407407+ "free space cache, dumping\n");408408+ kunmap(page);409409+ unlock_page(page);410410+ page_cache_release(page);411411+ goto free_cache;412412+ }406413 } else {407414 e->bitmap = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);408415 if (!e->bitmap) {···426419 ctl->op->recalc_thresholds(ctl);427420 spin_unlock(&ctl->tree_lock);428421 list_add_tail(&e->list, &bitmaps);422422+ if (ret) {423423+ printk(KERN_ERR "Duplicate entries in "424424+ "free space cache, dumping\n");425425+ kunmap(page);426426+ unlock_page(page);427427+ page_cache_release(page);428428+ goto free_cache;429429+ }429430 }430431431432 num_entries--;···493478 * If we're unmounting then just return, since this does a search on the494479 * normal root and not the commit root and we could deadlock.495480 */496496- smp_mb();497497- if (fs_info->closing)481481+ if (btrfs_fs_closing(fs_info))498482 return 0;499483500484 /*···589575590576 num_pages = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>591577 PAGE_CACHE_SHIFT;578578+579579+ /* Since the first page has all of our checksums and our generation we580580+ * need to calculate the offset into the page that we can start writing581581+ * our entries.582582+ */583583+ first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64);584584+592585 filemap_write_and_wait(inode->i_mapping);593586 btrfs_wait_ordered_range(inode, inode->i_size &594587 ~(root->sectorsize - 1), (u64)-1);588588+589589+ /* make sure we don't overflow that first page */590590+ if (first_page_offset + sizeof(struct btrfs_free_space_entry) >= PAGE_CACHE_SIZE) {591591+ /* this is really the same as running out of space, where we also return 0 */592592+ printk(KERN_CRIT "Btrfs: free space cache was too big for the crc page\n");593593+ ret = 0;594594+ goto out_update;595595+ }595596596597 /* We need a checksum per page. */597598 crc = checksums = kzalloc(sizeof(u32) * num_pages, GFP_NOFS);···618589 kfree(crc);619590 return -1;620591 }621621-622622- /* Since the first page has all of our checksums and our generation we623623- * need to calculate the offset into the page that we can start writing624624- * our entries.625625- */626626- first_page_offset = (sizeof(u32) * num_pages) + sizeof(u64);627592628593 /* Get the cluster for this block_group if it exists */629594 if (block_group && !list_empty(&block_group->cluster_list))···880857 ret = 1;881858882859out_free:860860+ kfree(checksums);861861+ kfree(pages);862862+863863+out_update:883864 if (ret != 1) {884865 invalidate_inode_pages2_range(inode->i_mapping, 0, index);885866 BTRFS_I(inode)->generation = 0;886867 }887887- kfree(checksums);888888- kfree(pages);889868 btrfs_update_inode(trans, root, inode);890869 return ret;891870}···988963 * logically.989964 */990965 if (bitmap) {991991- WARN_ON(info->bitmap);966966+ if (info->bitmap) {967967+ WARN_ON_ONCE(1);968968+ return -EEXIST;969969+ }992970 p = &(*p)->rb_right;993971 } else {994994- WARN_ON(!info->bitmap);972972+ if (!info->bitmap) {973973+ WARN_ON_ONCE(1);974974+ return -EEXIST;975975+ }995976 p = &(*p)->rb_left;996977 }997978 }···25122481 return inode;2513248225142483 spin_lock(&root->cache_lock);25152515- if (!root->fs_info->closing)24842484+ if (!btrfs_fs_closing(root->fs_info))25162485 root->cache_inode = igrab(inode);25172486 spin_unlock(&root->cache_lock);25182487···25352504 int ret = 0;25362505 u64 root_gen = btrfs_root_generation(&root->root_item);2537250625072507+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))25082508+ return 0;25092509+25382510 /*25392511 * If we're unmounting then just return, since this does a search on the25402512 * normal root and not the commit root and we could deadlock.25412513 */25422542- smp_mb();25432543- if (fs_info->closing)25142514+ if (btrfs_fs_closing(fs_info))25442515 return 0;2545251625462517 path = btrfs_alloc_path();···25752542 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;25762543 struct inode *inode;25772544 int ret;25452545+25462546+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))25472547+ return 0;2578254825792549 inode = lookup_free_ino_inode(root, path);25802550 if (IS_ERR(inode))
+32-2
fs/btrfs/inode-map.c
···3838 int slot;3939 int ret;40404141+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))4242+ return 0;4343+4144 path = btrfs_alloc_path();4245 if (!path)4346 return -ENOMEM;···6259 goto out;63606461 while (1) {6565- smp_mb();6666- if (fs_info->closing)6262+ if (btrfs_fs_closing(fs_info))6763 goto out;68646965 leaf = path->nodes[0];···143141 int ret;144142 u64 objectid;145143144144+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))145145+ return;146146+146147 spin_lock(&root->cache_lock);147148 if (root->cached != BTRFS_CACHE_NO) {148149 spin_unlock(&root->cache_lock);···183178184179int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)185180{181181+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))182182+ return btrfs_find_free_objectid(root, objectid);183183+186184again:187185 *objectid = btrfs_find_ino_for_alloc(root);188186···209201{210202 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;211203 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned;204204+205205+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))206206+ return;207207+212208again:213209 if (root->cached == BTRFS_CACHE_FINISHED) {214210 __btrfs_add_free_space(ctl, objectid, 1);···261249 struct btrfs_free_space *info;262250 struct rb_node *n;263251 u64 count;252252+253253+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))254254+ return;264255265256 while (1) {266257 n = rb_first(rbroot);···403388 int prealloc;404389 bool retry = false;405390391391+ /* only fs tree and subvol/snap needs ino cache */392392+ if (root->root_key.objectid != BTRFS_FS_TREE_OBJECTID &&393393+ (root->root_key.objectid < BTRFS_FIRST_FREE_OBJECTID ||394394+ root->root_key.objectid > BTRFS_LAST_FREE_OBJECTID))395395+ return 0;396396+397397+ /* Don't save inode cache if we are deleting this root */398398+ if (btrfs_root_refs(&root->root_item) == 0 &&399399+ root != root->fs_info->tree_root)400400+ return 0;401401+402402+ if (!btrfs_test_opt(root, INODE_MAP_CACHE))403403+ return 0;404404+406405 path = btrfs_alloc_path();407406 if (!path)408407 return -ENOMEM;408408+409409again:410410 inode = lookup_free_ino_inode(root, path);411411 if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) {
+137-124
fs/btrfs/inode.c
···138138 return -ENOMEM;139139140140 path->leave_spinning = 1;141141- btrfs_set_trans_block_group(trans, inode);142141143142 key.objectid = btrfs_ino(inode);144143 key.offset = start;···425426 }426427 }427428 if (start == 0) {428428- trans = btrfs_join_transaction(root, 1);429429+ trans = btrfs_join_transaction(root);429430 BUG_ON(IS_ERR(trans));430430- btrfs_set_trans_block_group(trans, inode);431431 trans->block_rsv = &root->fs_info->delalloc_block_rsv;432432433433 /* lets try to make an inline extent */···621623 async_extent->start + async_extent->ram_size - 1,622624 GFP_NOFS);623625624624- trans = btrfs_join_transaction(root, 1);626626+ trans = btrfs_join_transaction(root);625627 BUG_ON(IS_ERR(trans));628628+ trans->block_rsv = &root->fs_info->delalloc_block_rsv;626629 ret = btrfs_reserve_extent(trans, root,627630 async_extent->compressed_size,628631 async_extent->compressed_size,···792793 int ret = 0;793794794795 BUG_ON(is_free_space_inode(root, inode));795795- trans = btrfs_join_transaction(root, 1);796796+ trans = btrfs_join_transaction(root);796797 BUG_ON(IS_ERR(trans));797797- btrfs_set_trans_block_group(trans, inode);798798 trans->block_rsv = &root->fs_info->delalloc_block_rsv;799799800800 num_bytes = (end - start + blocksize) & ~(blocksize - 1);···10751077 nolock = is_free_space_inode(root, inode);1076107810771079 if (nolock)10781078- trans = btrfs_join_transaction_nolock(root, 1);10801080+ trans = btrfs_join_transaction_nolock(root);10791081 else10801080- trans = btrfs_join_transaction(root, 1);10821082+ trans = btrfs_join_transaction(root);10831083+10811084 BUG_ON(IS_ERR(trans));10851085+ trans->block_rsv = &root->fs_info->delalloc_block_rsv;1082108610831087 cow_start = (u64)-1;10841088 cur_offset = start;···15191519{15201520 struct btrfs_ordered_sum *sum;1521152115221522- btrfs_set_trans_block_group(trans, inode);15231523-15241522 list_for_each_entry(sum, list, list) {15251523 btrfs_csum_file_blocks(trans,15261524 BTRFS_I(inode)->root->fs_info->csum_root, sum);···17331735 ret = btrfs_ordered_update_i_size(inode, 0, ordered_extent);17341736 if (!ret) {17351737 if (nolock)17361736- trans = btrfs_join_transaction_nolock(root, 1);17381738+ trans = btrfs_join_transaction_nolock(root);17371739 else17381738- trans = btrfs_join_transaction(root, 1);17401740+ trans = btrfs_join_transaction(root);17391741 BUG_ON(IS_ERR(trans));17401740- btrfs_set_trans_block_group(trans, inode);17411742 trans->block_rsv = &root->fs_info->delalloc_block_rsv;17421743 ret = btrfs_update_inode(trans, root, inode);17431744 BUG_ON(ret);···17491752 0, &cached_state, GFP_NOFS);1750175317511754 if (nolock)17521752- trans = btrfs_join_transaction_nolock(root, 1);17551755+ trans = btrfs_join_transaction_nolock(root);17531756 else17541754- trans = btrfs_join_transaction(root, 1);17571757+ trans = btrfs_join_transaction(root);17551758 BUG_ON(IS_ERR(trans));17561756- btrfs_set_trans_block_group(trans, inode);17571759 trans->block_rsv = &root->fs_info->delalloc_block_rsv;1758176017591761 if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered_extent->flags))···24272431 (u64)-1);2428243224292433 if (root->orphan_block_rsv || root->orphan_item_inserted) {24302430- trans = btrfs_join_transaction(root, 1);24342434+ trans = btrfs_join_transaction(root);24312435 if (!IS_ERR(trans))24322436 btrfs_end_transaction(trans, root);24332437 }···25072511 struct btrfs_root *root = BTRFS_I(inode)->root;25082512 struct btrfs_key location;25092513 int maybe_acls;25102510- u64 alloc_group_block;25112514 u32 rdev;25122515 int ret;2513251625142517 path = btrfs_alloc_path();25152518 BUG_ON(!path);25192519+ path->leave_spinning = 1;25162520 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));2517252125182522 ret = btrfs_lookup_inode(NULL, root, path, &location, 0);···25222526 leaf = path->nodes[0];25232527 inode_item = btrfs_item_ptr(leaf, path->slots[0],25242528 struct btrfs_inode_item);25292529+ if (!leaf->map_token)25302530+ map_private_extent_buffer(leaf, (unsigned long)inode_item,25312531+ sizeof(struct btrfs_inode_item),25322532+ &leaf->map_token, &leaf->kaddr,25332533+ &leaf->map_start, &leaf->map_len,25342534+ KM_USER1);2525253525262536 inode->i_mode = btrfs_inode_mode(leaf, inode_item);25272537 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);···25572555 BTRFS_I(inode)->index_cnt = (u64)-1;25582556 BTRFS_I(inode)->flags = btrfs_inode_flags(leaf, inode_item);2559255725602560- alloc_group_block = btrfs_inode_block_group(leaf, inode_item);25612561-25622558 /*25632559 * try to precache a NULL acl entry for files that don't have25642560 * any xattrs or acls···25662566 if (!maybe_acls)25672567 cache_no_acl(inode);2568256825692569- BTRFS_I(inode)->block_group = btrfs_find_block_group(root, 0,25702570- alloc_group_block, 0);25692569+ if (leaf->map_token) {25702570+ unmap_extent_buffer(leaf, leaf->map_token, KM_USER1);25712571+ leaf->map_token = NULL;25722572+ }25732573+25712574 btrfs_free_path(path);25722575 inode_item = NULL;25732576···26502647 btrfs_set_inode_transid(leaf, item, trans->transid);26512648 btrfs_set_inode_rdev(leaf, item, inode->i_rdev);26522649 btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags);26532653- btrfs_set_inode_block_group(leaf, item, BTRFS_I(inode)->block_group);26502650+ btrfs_set_inode_block_group(leaf, item, 0);2654265126552652 if (leaf->map_token) {26562653 unmap_extent_buffer(leaf, leaf->map_token, KM_USER1);···30073004 if (IS_ERR(trans))30083005 return PTR_ERR(trans);3009300630103010- btrfs_set_trans_block_group(trans, dir);30113011-30123007 btrfs_record_unlink_dir(trans, dir, dentry->d_inode, 0);3013300830143009 ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,···30943093 trans = __unlink_start_trans(dir, dentry);30953094 if (IS_ERR(trans))30963095 return PTR_ERR(trans);30973097-30983098- btrfs_set_trans_block_group(trans, dir);3099309631003097 if (unlikely(btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {31013098 err = btrfs_unlink_subvol(trans, root, dir,···35133514 err = PTR_ERR(trans);35143515 break;35153516 }35163516- btrfs_set_trans_block_group(trans, inode);3517351735183518 err = btrfs_drop_extents(trans, inode, cur_offset,35193519 cur_offset + hole_size,···36483650 while (1) {36493651 trans = btrfs_start_transaction(root, 0);36503652 BUG_ON(IS_ERR(trans));36513651- btrfs_set_trans_block_group(trans, inode);36523653 trans->block_rsv = root->orphan_block_rsv;3653365436543655 ret = btrfs_block_rsv_check(trans, root,···41304133 path = btrfs_alloc_path();41314134 if (!path)41324135 return -ENOMEM;41334133- path->reada = 2;41364136+41374137+ path->reada = 1;4134413841354139 if (key_type == BTRFS_DIR_INDEX_KEY) {41364140 INIT_LIST_HEAD(&ins_list);···42664268 if (BTRFS_I(inode)->dummy_inode)42674269 return 0;4268427042694269- smp_mb();42704270- if (root->fs_info->closing && is_free_space_inode(root, inode))42714271+ if (btrfs_fs_closing(root->fs_info) && is_free_space_inode(root, inode))42714272 nolock = true;4272427342734274 if (wbc->sync_mode == WB_SYNC_ALL) {42744275 if (nolock)42754275- trans = btrfs_join_transaction_nolock(root, 1);42764276+ trans = btrfs_join_transaction_nolock(root);42764277 else42774277- trans = btrfs_join_transaction(root, 1);42784278+ trans = btrfs_join_transaction(root);42784279 if (IS_ERR(trans))42794280 return PTR_ERR(trans);42804280- btrfs_set_trans_block_group(trans, inode);42814281 if (nolock)42824282 ret = btrfs_end_transaction_nolock(trans, root);42834283 else···42994303 if (BTRFS_I(inode)->dummy_inode)43004304 return;4301430543024302- trans = btrfs_join_transaction(root, 1);43064306+ trans = btrfs_join_transaction(root);43034307 BUG_ON(IS_ERR(trans));43044304- btrfs_set_trans_block_group(trans, inode);4305430843064309 ret = btrfs_update_inode(trans, root, inode);43074310 if (ret && ret == -ENOSPC) {···43144319 PTR_ERR(trans));43154320 return;43164321 }43174317- btrfs_set_trans_block_group(trans, inode);4318432243194323 ret = btrfs_update_inode(trans, root, inode);43204324 if (ret) {···44124418 struct btrfs_root *root,44134419 struct inode *dir,44144420 const char *name, int name_len,44154415- u64 ref_objectid, u64 objectid,44164416- u64 alloc_hint, int mode, u64 *index)44214421+ u64 ref_objectid, u64 objectid, int mode,44224422+ u64 *index)44174423{44184424 struct inode *inode;44194425 struct btrfs_inode_item *inode_item;···44664472 owner = 0;44674473 else44684474 owner = 1;44694469- BTRFS_I(inode)->block_group =44704470- btrfs_find_block_group(root, 0, alloc_hint, owner);4471447544724476 key[0].objectid = objectid;44734477 btrfs_set_key_type(&key[0], BTRFS_INODE_ITEM_KEY);···46214629 if (IS_ERR(trans))46224630 return PTR_ERR(trans);4623463146244624- btrfs_set_trans_block_group(trans, dir);46254625-46264632 err = btrfs_find_free_ino(root, &objectid);46274633 if (err)46284634 goto out_unlock;4629463546304636 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,46314637 dentry->d_name.len, btrfs_ino(dir), objectid,46324632- BTRFS_I(dir)->block_group, mode, &index);46384638+ mode, &index);46334639 if (IS_ERR(inode)) {46344640 err = PTR_ERR(inode);46354641 goto out_unlock;···46394649 goto out_unlock;46404650 }4641465146424642- btrfs_set_trans_block_group(trans, inode);46434652 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);46444653 if (err)46454654 drop_inode = 1;···46474658 init_special_inode(inode, inode->i_mode, rdev);46484659 btrfs_update_inode(trans, root, inode);46494660 }46504650- btrfs_update_inode_block_group(trans, inode);46514651- btrfs_update_inode_block_group(trans, dir);46524661out_unlock:46534662 nr = trans->blocks_used;46544663 btrfs_end_transaction_throttle(trans, root);···46794692 if (IS_ERR(trans))46804693 return PTR_ERR(trans);4681469446824682- btrfs_set_trans_block_group(trans, dir);46834683-46844695 err = btrfs_find_free_ino(root, &objectid);46854696 if (err)46864697 goto out_unlock;4687469846884699 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,46894700 dentry->d_name.len, btrfs_ino(dir), objectid,46904690- BTRFS_I(dir)->block_group, mode, &index);47014701+ mode, &index);46914702 if (IS_ERR(inode)) {46924703 err = PTR_ERR(inode);46934704 goto out_unlock;···46974712 goto out_unlock;46984713 }4699471447004700- btrfs_set_trans_block_group(trans, inode);47014715 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);47024716 if (err)47034717 drop_inode = 1;···47074723 inode->i_op = &btrfs_file_inode_operations;47084724 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;47094725 }47104710- btrfs_update_inode_block_group(trans, inode);47114711- btrfs_update_inode_block_group(trans, dir);47124726out_unlock:47134727 nr = trans->blocks_used;47144728 btrfs_end_transaction_throttle(trans, root);···4753477147544772 btrfs_inc_nlink(inode);47554773 inode->i_ctime = CURRENT_TIME;47564756-47574757- btrfs_set_trans_block_group(trans, dir);47584774 ihold(inode);4759477547604776 err = btrfs_add_nondir(trans, dir, dentry, inode, 1, index);···47614781 drop_inode = 1;47624782 } else {47634783 struct dentry *parent = dget_parent(dentry);47644764- btrfs_update_inode_block_group(trans, dir);47654784 err = btrfs_update_inode(trans, root, inode);47664785 BUG_ON(err);47674786 btrfs_log_new_name(trans, inode, NULL, parent);···47974818 trans = btrfs_start_transaction(root, 5);47984819 if (IS_ERR(trans))47994820 return PTR_ERR(trans);48004800- btrfs_set_trans_block_group(trans, dir);4801482148024822 err = btrfs_find_free_ino(root, &objectid);48034823 if (err)···4804482648054827 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,48064828 dentry->d_name.len, btrfs_ino(dir), objectid,48074807- BTRFS_I(dir)->block_group, S_IFDIR | mode,48084808- &index);48294829+ S_IFDIR | mode, &index);48094830 if (IS_ERR(inode)) {48104831 err = PTR_ERR(inode);48114832 goto out_fail;···4818484148194842 inode->i_op = &btrfs_dir_inode_operations;48204843 inode->i_fop = &btrfs_dir_file_operations;48214821- btrfs_set_trans_block_group(trans, inode);4822484448234845 btrfs_i_size_write(inode, 0);48244846 err = btrfs_update_inode(trans, root, inode);···4831485548324856 d_instantiate(dentry, inode);48334857 drop_on_err = 0;48344834- btrfs_update_inode_block_group(trans, inode);48354835- btrfs_update_inode_block_group(trans, dir);4836485848374859out_fail:48384860 nr = trans->blocks_used;···4963498949644990 if (!path) {49654991 path = btrfs_alloc_path();49664966- BUG_ON(!path);49924992+ if (!path) {49934993+ err = -ENOMEM;49944994+ goto out;49954995+ }49964996+ /*49974997+ * Chances are we'll be called again, so go ahead and do49984998+ * readahead49994999+ */50005000+ path->reada = 1;49675001 }4968500249695003 ret = btrfs_lookup_file_extent(trans, root, path,···51125130 kunmap(page);51135131 free_extent_map(em);51145132 em = NULL;51335133+51155134 btrfs_release_path(path);51165116- trans = btrfs_join_transaction(root, 1);51355135+ trans = btrfs_join_transaction(root);51365136+51175137 if (IS_ERR(trans))51185138 return ERR_CAST(trans);51195139 goto again;···53595375 btrfs_drop_extent_cache(inode, start, start + len - 1, 0);53605376 }5361537753625362- trans = btrfs_join_transaction(root, 0);53785378+ trans = btrfs_join_transaction(root);53635379 if (IS_ERR(trans))53645380 return ERR_CAST(trans);53655381···55955611 * to make sure the current transaction stays open55965612 * while we look for nocow cross refs55975613 */55985598- trans = btrfs_join_transaction(root, 0);56145614+ trans = btrfs_join_transaction(root);55995615 if (IS_ERR(trans))56005616 goto must_cow;56015617···5734575057355751 BUG_ON(!ordered);5736575257375737- trans = btrfs_join_transaction(root, 1);57535753+ trans = btrfs_join_transaction(root);57385754 if (IS_ERR(trans)) {57395755 err = -ENOMEM;57405756 goto out;···64846500static int btrfs_truncate(struct inode *inode)64856501{64866502 struct btrfs_root *root = BTRFS_I(inode)->root;65036503+ struct btrfs_block_rsv *rsv;64876504 int ret;64886505 int err = 0;64896506 struct btrfs_trans_handle *trans;···64986513 btrfs_wait_ordered_range(inode, inode->i_size & (~mask), (u64)-1);64996514 btrfs_ordered_update_i_size(inode, inode->i_size, NULL);6500651565016501- trans = btrfs_start_transaction(root, 5);65026502- if (IS_ERR(trans))65036503- return PTR_ERR(trans);65166516+ /*65176517+ * Yes ladies and gentelment, this is indeed ugly. The fact is we have65186518+ * 3 things going on here65196519+ *65206520+ * 1) We need to reserve space for our orphan item and the space to65216521+ * delete our orphan item. Lord knows we don't want to have a dangling65226522+ * orphan item because we didn't reserve space to remove it.65236523+ *65246524+ * 2) We need to reserve space to update our inode.65256525+ *65266526+ * 3) We need to have something to cache all the space that is going to65276527+ * be free'd up by the truncate operation, but also have some slack65286528+ * space reserved in case it uses space during the truncate (thank you65296529+ * very much snapshotting).65306530+ *65316531+ * And we need these to all be seperate. The fact is we can use alot of65326532+ * space doing the truncate, and we have no earthly idea how much space65336533+ * we will use, so we need the truncate reservation to be seperate so it65346534+ * doesn't end up using space reserved for updating the inode or65356535+ * removing the orphan item. We also need to be able to stop the65366536+ * transaction and start a new one, which means we need to be able to65376537+ * update the inode several times, and we have no idea of knowing how65386538+ * many times that will be, so we can't just reserve 1 item for the65396539+ * entirety of the opration, so that has to be done seperately as well.65406540+ * Then there is the orphan item, which does indeed need to be held on65416541+ * to for the whole operation, and we need nobody to touch this reserved65426542+ * space except the orphan code.65436543+ *65446544+ * So that leaves us with65456545+ *65466546+ * 1) root->orphan_block_rsv - for the orphan deletion.65476547+ * 2) rsv - for the truncate reservation, which we will steal from the65486548+ * transaction reservation.65496549+ * 3) fs_info->trans_block_rsv - this will have 1 items worth left for65506550+ * updating the inode.65516551+ */65526552+ rsv = btrfs_alloc_block_rsv(root);65536553+ if (!rsv)65546554+ return -ENOMEM;65556555+ btrfs_add_durable_block_rsv(root->fs_info, rsv);6504655665056505- btrfs_set_trans_block_group(trans, inode);65576557+ trans = btrfs_start_transaction(root, 4);65586558+ if (IS_ERR(trans)) {65596559+ err = PTR_ERR(trans);65606560+ goto out;65616561+ }65626562+65636563+ /*65646564+ * Reserve space for the truncate process. Truncate should be adding65656565+ * space, but if there are snapshots it may end up using space.65666566+ */65676567+ ret = btrfs_truncate_reserve_metadata(trans, root, rsv);65686568+ BUG_ON(ret);6506656965076570 ret = btrfs_orphan_add(trans, inode);65086571 if (ret) {65096572 btrfs_end_transaction(trans, root);65106510- return ret;65736573+ goto out;65116574 }6512657565136576 nr = trans->blocks_used;65146577 btrfs_end_transaction(trans, root);65156578 btrfs_btree_balance_dirty(root, nr);6516657965176517- /* Now start a transaction for the truncate */65186518- trans = btrfs_start_transaction(root, 0);65196519- if (IS_ERR(trans))65206520- return PTR_ERR(trans);65216521- btrfs_set_trans_block_group(trans, inode);65226522- trans->block_rsv = root->orphan_block_rsv;65806580+ /*65816581+ * Ok so we've already migrated our bytes over for the truncate, so here65826582+ * just reserve the one slot we need for updating the inode.65836583+ */65846584+ trans = btrfs_start_transaction(root, 1);65856585+ if (IS_ERR(trans)) {65866586+ err = PTR_ERR(trans);65876587+ goto out;65886588+ }65896589+ trans->block_rsv = rsv;6523659065246591 /*65256592 * setattr is responsible for setting the ordered_data_close flag,···6595655865966559 while (1) {65976560 if (!trans) {65986598- trans = btrfs_start_transaction(root, 0);65996599- if (IS_ERR(trans))66006600- return PTR_ERR(trans);66016601- btrfs_set_trans_block_group(trans, inode);66026602- trans->block_rsv = root->orphan_block_rsv;66036603- }65616561+ trans = btrfs_start_transaction(root, 3);65626562+ if (IS_ERR(trans)) {65636563+ err = PTR_ERR(trans);65646564+ goto out;65656565+ }6604656666056605- ret = btrfs_block_rsv_check(trans, root,66066606- root->orphan_block_rsv, 0, 5);66076607- if (ret == -EAGAIN) {66086608- ret = btrfs_commit_transaction(trans, root);66096609- if (ret)66106610- return ret;66116611- trans = NULL;66126612- continue;66136613- } else if (ret) {66146614- err = ret;66156615- break;65676567+ ret = btrfs_truncate_reserve_metadata(trans, root,65686568+ rsv);65696569+ BUG_ON(ret);65706570+65716571+ trans->block_rsv = rsv;66166572 }6617657366186574 ret = btrfs_truncate_inode_items(trans, root, inode,···66166586 break;66176587 }6618658865896589+ trans->block_rsv = &root->fs_info->trans_block_rsv;66196590 ret = btrfs_update_inode(trans, root, inode);66206591 if (ret) {66216592 err = ret;···66306599 }6631660066326601 if (ret == 0 && inode->i_nlink > 0) {66026602+ trans->block_rsv = root->orphan_block_rsv;66336603 ret = btrfs_orphan_del(trans, inode);66346604 if (ret)66356605 err = ret;···66426610 ret = btrfs_orphan_del(NULL, inode);66436611 }6644661266136613+ trans->block_rsv = &root->fs_info->trans_block_rsv;66456614 ret = btrfs_update_inode(trans, root, inode);66466615 if (ret && !err)66476616 err = ret;6648661766496618 nr = trans->blocks_used;66506619 ret = btrfs_end_transaction_throttle(trans, root);66206620+ btrfs_btree_balance_dirty(root, nr);66216621+66226622+out:66236623+ btrfs_free_block_rsv(root, rsv);66246624+66516625 if (ret && !err)66526626 err = ret;66536653- btrfs_btree_balance_dirty(root, nr);6654662766556628 return err;66566629}···66646627 * create a new subvolume directory/inode (helper for the ioctl).66656628 */66666629int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,66676667- struct btrfs_root *new_root,66686668- u64 new_dirid, u64 alloc_hint)66306630+ struct btrfs_root *new_root, u64 new_dirid)66696631{66706632 struct inode *inode;66716633 int err;66726634 u64 index = 0;6673663566746636 inode = btrfs_new_inode(trans, new_root, NULL, "..", 2, new_dirid,66756675- new_dirid, alloc_hint, S_IFDIR | 0700, &index);66376637+ new_dirid, S_IFDIR | 0700, &index);66766638 if (IS_ERR(inode))66776639 return PTR_ERR(inode);66786640 inode->i_op = &btrfs_dir_inode_operations;···67826746 spin_lock(&root->fs_info->ordered_extent_lock);67836747 list_del_init(&BTRFS_I(inode)->ordered_operations);67846748 spin_unlock(&root->fs_info->ordered_extent_lock);67856785- }67866786-67876787- if (root == root->fs_info->tree_root) {67886788- struct btrfs_block_group_cache *block_group;67896789-67906790- block_group = btrfs_lookup_block_group(root->fs_info,67916791- BTRFS_I(inode)->block_group);67926792- if (block_group && block_group->inode == inode) {67936793- spin_lock(&block_group->lock);67946794- block_group->inode = NULL;67956795- spin_unlock(&block_group->lock);67966796- btrfs_put_block_group(block_group);67976797- } else if (block_group) {67986798- btrfs_put_block_group(block_group);67996799- }68006749 }6801675068026751 spin_lock(&root->orphan_lock);···69696948 goto out_notrans;69706949 }6971695069726972- btrfs_set_trans_block_group(trans, new_dir);69736973-69746951 if (dest != root)69756952 btrfs_record_root_in_trans(trans, dest);69766953···71507131 if (IS_ERR(trans))71517132 return PTR_ERR(trans);7152713371537153- btrfs_set_trans_block_group(trans, dir);71547154-71557134 err = btrfs_find_free_ino(root, &objectid);71567135 if (err)71577136 goto out_unlock;7158713771597138 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,71607139 dentry->d_name.len, btrfs_ino(dir), objectid,71617161- BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,71627162- &index);71407140+ S_IFLNK|S_IRWXUGO, &index);71637141 if (IS_ERR(inode)) {71647142 err = PTR_ERR(inode);71657143 goto out_unlock;···71687152 goto out_unlock;71697153 }7170715471717171- btrfs_set_trans_block_group(trans, inode);71727155 err = btrfs_add_nondir(trans, dir, dentry, inode, 0, index);71737156 if (err)71747157 drop_inode = 1;···71787163 inode->i_op = &btrfs_file_inode_operations;71797164 BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;71807165 }71817181- btrfs_update_inode_block_group(trans, inode);71827182- btrfs_update_inode_block_group(trans, dir);71837166 if (drop_inode)71847167 goto out_unlock;71857168
+10-16
fs/btrfs/ioctl.c
···243243 ip->flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);244244 }245245246246- trans = btrfs_join_transaction(root, 1);246246+ trans = btrfs_join_transaction(root);247247 BUG_ON(IS_ERR(trans));248248249249 ret = btrfs_update_inode(trans, root, inode);···414414415415 btrfs_record_root_in_trans(trans, new_root);416416417417- ret = btrfs_create_subvol_root(trans, new_root, new_dirid,418418- BTRFS_I(dir)->block_group);417417+ ret = btrfs_create_subvol_root(trans, new_root, new_dirid);419418 /*420419 * insert the directory item421420 */···706707 struct btrfs_file_extent_item *extent;707708 int type;708709 int ret;710710+ u64 ino = btrfs_ino(inode);709711710712 path = btrfs_alloc_path();711713 if (!path)712714 return -ENOMEM;713715714714- min_key.objectid = inode->i_ino;716716+ min_key.objectid = ino;715717 min_key.type = BTRFS_EXTENT_DATA_KEY;716718 min_key.offset = *off;717719718718- max_key.objectid = inode->i_ino;720720+ max_key.objectid = ino;719721 max_key.type = (u8)-1;720722 max_key.offset = (u64)-1;721723···727727 path, 0, newer_than);728728 if (ret != 0)729729 goto none;730730- if (min_key.objectid != inode->i_ino)730730+ if (min_key.objectid != ino)731731 goto none;732732 if (min_key.type != BTRFS_EXTENT_DATA_KEY)733733 goto none;···24892489 if (ret)24902490 goto out;2491249124922492- mutex_lock(&root->fs_info->trans_mutex);24932493- root->fs_info->open_ioctl_trans++;24942494- mutex_unlock(&root->fs_info->trans_mutex);24922492+ atomic_inc(&root->fs_info->open_ioctl_trans);2495249324962494 ret = -ENOMEM;24972497- trans = btrfs_start_ioctl_transaction(root, 0);24952495+ trans = btrfs_start_ioctl_transaction(root);24982496 if (IS_ERR(trans))24992497 goto out_drop;25002498···25002502 return 0;2501250325022504out_drop:25032503- mutex_lock(&root->fs_info->trans_mutex);25042504- root->fs_info->open_ioctl_trans--;25052505- mutex_unlock(&root->fs_info->trans_mutex);25052505+ atomic_dec(&root->fs_info->open_ioctl_trans);25062506 mnt_drop_write(file->f_path.mnt);25072507out:25082508 return ret;···2734273827352739 btrfs_end_transaction(trans, root);2736274027372737- mutex_lock(&root->fs_info->trans_mutex);27382738- root->fs_info->open_ioctl_trans--;27392739- mutex_unlock(&root->fs_info->trans_mutex);27412741+ atomic_dec(&root->fs_info->open_ioctl_trans);2740274227412743 mnt_drop_write(file->f_path.mnt);27422744 return 0;
+20-14
fs/btrfs/relocation.c
···677677 err = -ENOMEM;678678 goto out;679679 }680680+ path1->reada = 1;681681+ path2->reada = 2;680682681683 node = alloc_backref_node(cache);682684 if (!node) {···20011999 path = btrfs_alloc_path();20022000 if (!path)20032001 return -ENOMEM;20022002+ path->reada = 1;2004200320052004 reloc_root = root->reloc_root;20062005 root_item = &reloc_root->root_item;···21422139 u64 num_bytes = 0;21432140 int ret;2144214121452145- mutex_lock(&root->fs_info->trans_mutex);21422142+ spin_lock(&root->fs_info->trans_lock);21462143 rc->merging_rsv_size += root->nodesize * (BTRFS_MAX_LEVEL - 1) * 2;21472144 rc->merging_rsv_size += rc->nodes_relocated * 2;21482148- mutex_unlock(&root->fs_info->trans_mutex);21452145+ spin_unlock(&root->fs_info->trans_lock);21492146again:21502147 if (!err) {21512148 num_bytes = rc->merging_rsv_size;···21552152 err = ret;21562153 }2157215421582158- trans = btrfs_join_transaction(rc->extent_root, 1);21552155+ trans = btrfs_join_transaction(rc->extent_root);21592156 if (IS_ERR(trans)) {21602157 if (!err)21612158 btrfs_block_rsv_release(rc->extent_root,···22142211 int ret;22152212again:22162213 root = rc->extent_root;22172217- mutex_lock(&root->fs_info->trans_mutex);22142214+ spin_lock(&root->fs_info->trans_lock);22182215 list_splice_init(&rc->reloc_roots, &reloc_roots);22192219- mutex_unlock(&root->fs_info->trans_mutex);22162216+ spin_unlock(&root->fs_info->trans_lock);2220221722212218 while (!list_empty(&reloc_roots)) {22222219 found = 1;···32393236 goto out;32403237 }3241323832423242- trans = btrfs_join_transaction(root, 0);32393239+ trans = btrfs_join_transaction(root);32433240 if (IS_ERR(trans)) {32443241 btrfs_free_path(path);32453242 ret = PTR_ERR(trans);···33033300 path = btrfs_alloc_path();33043301 if (!path)33053302 return -ENOMEM;33033303+ path->reada = 1;3306330433073305 root = read_fs_root(rc->extent_root->fs_info, ref_root);33083306 if (IS_ERR(root)) {···35903586static void set_reloc_control(struct reloc_control *rc)35913587{35923588 struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;35933593- mutex_lock(&fs_info->trans_mutex);35893589+ spin_lock(&fs_info->trans_lock);35943590 fs_info->reloc_ctl = rc;35953595- mutex_unlock(&fs_info->trans_mutex);35913591+ spin_unlock(&fs_info->trans_lock);35963592}3597359335983594static void unset_reloc_control(struct reloc_control *rc)35993595{36003596 struct btrfs_fs_info *fs_info = rc->extent_root->fs_info;36013601- mutex_lock(&fs_info->trans_mutex);35973597+ spin_lock(&fs_info->trans_lock);36023598 fs_info->reloc_ctl = NULL;36033603- mutex_unlock(&fs_info->trans_mutex);35993599+ spin_unlock(&fs_info->trans_lock);36043600}3605360136063602static int check_extent_flags(u64 flags)···36493645 rc->create_reloc_tree = 1;36503646 set_reloc_control(rc);3651364736523652- trans = btrfs_join_transaction(rc->extent_root, 1);36483648+ trans = btrfs_join_transaction(rc->extent_root);36533649 BUG_ON(IS_ERR(trans));36543650 btrfs_commit_transaction(trans, rc->extent_root);36553651 return 0;···36723668 path = btrfs_alloc_path();36733669 if (!path)36743670 return -ENOMEM;36713671+ path->reada = 1;3675367236763673 ret = prepare_to_relocate(rc);36773674 if (ret) {···38393834 btrfs_block_rsv_release(rc->extent_root, rc->block_rsv, (u64)-1);3840383538413836 /* get rid of pinned extents */38423842- trans = btrfs_join_transaction(rc->extent_root, 1);38373837+ trans = btrfs_join_transaction(rc->extent_root);38433838 if (IS_ERR(trans))38443839 err = PTR_ERR(trans);38453840 else···40984093 path = btrfs_alloc_path();40994094 if (!path)41004095 return -ENOMEM;40964096+ path->reada = -1;4101409741024098 key.objectid = BTRFS_TREE_RELOC_OBJECTID;41034099 key.type = BTRFS_ROOT_ITEM_KEY;···4165415941664160 set_reloc_control(rc);4167416141684168- trans = btrfs_join_transaction(rc->extent_root, 1);41624162+ trans = btrfs_join_transaction(rc->extent_root);41694163 if (IS_ERR(trans)) {41704164 unset_reloc_control(rc);41714165 err = PTR_ERR(trans);···4199419342004194 unset_reloc_control(rc);4201419542024202- trans = btrfs_join_transaction(rc->extent_root, 1);41964196+ trans = btrfs_join_transaction(rc->extent_root);42034197 if (IS_ERR(trans))42044198 err = PTR_ERR(trans);42054199 else
+70-53
fs/btrfs/scrub.c
···117117 }118118}119119120120+static void scrub_free_bio(struct bio *bio)121121+{122122+ int i;123123+ struct page *last_page = NULL;124124+125125+ if (!bio)126126+ return;127127+128128+ for (i = 0; i < bio->bi_vcnt; ++i) {129129+ if (bio->bi_io_vec[i].bv_page == last_page)130130+ continue;131131+ last_page = bio->bi_io_vec[i].bv_page;132132+ __free_page(last_page);133133+ }134134+ bio_put(bio);135135+}136136+120137static noinline_for_stack void scrub_free_dev(struct scrub_dev *sdev)121138{122139 int i;123123- int j;124124- struct page *last_page;125140126141 if (!sdev)127142 return;128143129144 for (i = 0; i < SCRUB_BIOS_PER_DEV; ++i) {130145 struct scrub_bio *sbio = sdev->bios[i];131131- struct bio *bio;132146133147 if (!sbio)134148 break;135149136136- bio = sbio->bio;137137- if (bio) {138138- last_page = NULL;139139- for (j = 0; j < bio->bi_vcnt; ++j) {140140- if (bio->bi_io_vec[j].bv_page == last_page)141141- continue;142142- last_page = bio->bi_io_vec[j].bv_page;143143- __free_page(last_page);144144- }145145- bio_put(bio);146146- }150150+ scrub_free_bio(sbio->bio);147151 kfree(sbio);148152 }149153···160156{161157 struct scrub_dev *sdev;162158 int i;163163- int j;164164- int ret;165159 struct btrfs_fs_info *fs_info = dev->dev_root->fs_info;166160167161 sdev = kzalloc(sizeof(*sdev), GFP_NOFS);···167165 goto nomem;168166 sdev->dev = dev;169167 for (i = 0; i < SCRUB_BIOS_PER_DEV; ++i) {170170- struct bio *bio;171168 struct scrub_bio *sbio;172169173170 sbio = kzalloc(sizeof(*sbio), GFP_NOFS);···174173 goto nomem;175174 sdev->bios[i] = sbio;176175177177- bio = bio_kmalloc(GFP_NOFS, SCRUB_PAGES_PER_BIO);178178- if (!bio)179179- goto nomem;180180-181176 sbio->index = i;182177 sbio->sdev = sdev;183183- sbio->bio = bio;184178 sbio->count = 0;185179 sbio->work.func = scrub_checksum;186186- bio->bi_private = sdev->bios[i];187187- bio->bi_end_io = scrub_bio_end_io;188188- bio->bi_sector = 0;189189- bio->bi_bdev = dev->bdev;190190- bio->bi_size = 0;191191-192192- for (j = 0; j < SCRUB_PAGES_PER_BIO; ++j) {193193- struct page *page;194194- page = alloc_page(GFP_NOFS);195195- if (!page)196196- goto nomem;197197-198198- ret = bio_add_page(bio, page, PAGE_SIZE, 0);199199- if (!ret)200200- goto nomem;201201- }202202- WARN_ON(bio->bi_vcnt != SCRUB_PAGES_PER_BIO);203180204181 if (i != SCRUB_BIOS_PER_DEV-1)205182 sdev->bios[i]->next_free = i + 1;···348369 int ret;349370 DECLARE_COMPLETION_ONSTACK(complete);350371351351- /* we are going to wait on this IO */352352- rw |= REQ_SYNC;353353-354372 bio = bio_alloc(GFP_NOFS, 1);355373 bio->bi_bdev = bdev;356374 bio->bi_sector = sector;···356380 bio->bi_private = &complete;357381 submit_bio(rw, bio);358382383383+ /* this will also unplug the queue */359384 wait_for_completion(&complete);360385361386 ret = !test_bit(BIO_UPTODATE, &bio->bi_flags);···371394 struct btrfs_fs_info *fs_info = sdev->dev->dev_root->fs_info;372395373396 sbio->err = err;397397+ sbio->bio = bio;374398375399 btrfs_queue_worker(&fs_info->scrub_workers, &sbio->work);376400}···431453 }432454433455out:456456+ scrub_free_bio(sbio->bio);457457+ sbio->bio = NULL;434458 spin_lock(&sdev->list_lock);435459 sbio->next_free = sdev->first_free;436460 sdev->first_free = sbio->index;···563583static int scrub_submit(struct scrub_dev *sdev)564584{565585 struct scrub_bio *sbio;586586+ struct bio *bio;587587+ int i;566588567589 if (sdev->curr == -1)568590 return 0;569591570592 sbio = sdev->bios[sdev->curr];571593572572- sbio->bio->bi_sector = sbio->physical >> 9;573573- sbio->bio->bi_size = sbio->count * PAGE_SIZE;574574- sbio->bio->bi_next = NULL;575575- sbio->bio->bi_flags |= 1 << BIO_UPTODATE;576576- sbio->bio->bi_comp_cpu = -1;577577- sbio->bio->bi_bdev = sdev->dev->bdev;594594+ bio = bio_alloc(GFP_NOFS, sbio->count);595595+ if (!bio)596596+ goto nomem;597597+598598+ bio->bi_private = sbio;599599+ bio->bi_end_io = scrub_bio_end_io;600600+ bio->bi_bdev = sdev->dev->bdev;601601+ bio->bi_sector = sbio->physical >> 9;602602+603603+ for (i = 0; i < sbio->count; ++i) {604604+ struct page *page;605605+ int ret;606606+607607+ page = alloc_page(GFP_NOFS);608608+ if (!page)609609+ goto nomem;610610+611611+ ret = bio_add_page(bio, page, PAGE_SIZE, 0);612612+ if (!ret) {613613+ __free_page(page);614614+ goto nomem;615615+ }616616+ }617617+578618 sbio->err = 0;579619 sdev->curr = -1;580620 atomic_inc(&sdev->in_flight);581621582582- submit_bio(0, sbio->bio);622622+ submit_bio(READ, bio);583623584624 return 0;625625+626626+nomem:627627+ scrub_free_bio(bio);628628+629629+ return -ENOMEM;585630}586631587632static int scrub_page(struct scrub_dev *sdev, u64 logical, u64 len,···638633 sbio->logical = logical;639634 } else if (sbio->physical + sbio->count * PAGE_SIZE != physical ||640635 sbio->logical + sbio->count * PAGE_SIZE != logical) {641641- scrub_submit(sdev);636636+ int ret;637637+638638+ ret = scrub_submit(sdev);639639+ if (ret)640640+ return ret;642641 goto again;643642 }644643 sbio->spag[sbio->count].flags = flags;···654645 memcpy(sbio->spag[sbio->count].csum, csum, sdev->csum_size);655646 }656647 ++sbio->count;657657- if (sbio->count == SCRUB_PAGES_PER_BIO || force)658658- scrub_submit(sdev);648648+ if (sbio->count == SCRUB_PAGES_PER_BIO || force) {649649+ int ret;650650+651651+ ret = scrub_submit(sdev);652652+ if (ret)653653+ return ret;654654+ }659655660656 return 0;661657}···741727 struct btrfs_root *root = fs_info->extent_root;742728 struct btrfs_root *csum_root = fs_info->csum_root;743729 struct btrfs_extent_item *extent;730730+ struct blk_plug plug;744731 u64 flags;745732 int ret;746733 int slot;···846831 * the scrub. This might currently (crc32) end up to be about 1MB847832 */848833 start_stripe = 0;834834+ blk_start_plug(&plug);849835again:850836 logical = base + offset + start_stripe * increment;851837 for (i = start_stripe; i < nstripes; ++i) {···988972 scrub_submit(sdev);989973990974out:975975+ blk_finish_plug(&plug);991976 btrfs_free_path(path);992977 return ret < 0 ? ret : 0;993978}···11831166 int ret;11841167 struct btrfs_device *dev;1185116811861186- if (root->fs_info->closing)11691169+ if (btrfs_fs_closing(root->fs_info))11871170 return -EINVAL;1188117111891172 /*
+7-1
fs/btrfs/super.c
···161161 Opt_compress_type, Opt_compress_force, Opt_compress_force_type,162162 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,163163 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,164164- Opt_enospc_debug, Opt_subvolrootid, Opt_defrag, Opt_err,164164+ Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,165165+ Opt_inode_cache, Opt_err,165166};166167167168static match_table_t tokens = {···194193 {Opt_enospc_debug, "enospc_debug"},195194 {Opt_subvolrootid, "subvolrootid=%d"},196195 {Opt_defrag, "autodefrag"},196196+ {Opt_inode_cache, "inode_cache"},197197 {Opt_err, NULL},198198};199199···362360 case Opt_space_cache:363361 printk(KERN_INFO "btrfs: enabling disk space caching\n");364362 btrfs_set_opt(info->mount_opt, SPACE_CACHE);363363+ break;364364+ case Opt_inode_cache:365365+ printk(KERN_INFO "btrfs: enabling inode map caching\n");366366+ btrfs_set_opt(info->mount_opt, INODE_MAP_CACHE);365367 break;366368 case Opt_clear_cache:367369 printk(KERN_INFO "btrfs: force clearing of disk cache\n");
+164-138
fs/btrfs/transaction.c
···3535{3636 WARN_ON(atomic_read(&transaction->use_count) == 0);3737 if (atomic_dec_and_test(&transaction->use_count)) {3838+ BUG_ON(!list_empty(&transaction->list));3839 memset(transaction, 0, sizeof(*transaction));3940 kmem_cache_free(btrfs_transaction_cachep, transaction);4041 }···5049/*5150 * either allocate a new transaction or hop into the existing one5251 */5353-static noinline int join_transaction(struct btrfs_root *root)5252+static noinline int join_transaction(struct btrfs_root *root, int nofail)5453{5554 struct btrfs_transaction *cur_trans;5555+5656+ spin_lock(&root->fs_info->trans_lock);5757+ if (root->fs_info->trans_no_join) {5858+ if (!nofail) {5959+ spin_unlock(&root->fs_info->trans_lock);6060+ return -EBUSY;6161+ }6262+ }6363+5664 cur_trans = root->fs_info->running_transaction;5757- if (!cur_trans) {5858- cur_trans = kmem_cache_alloc(btrfs_transaction_cachep,5959- GFP_NOFS);6060- if (!cur_trans)6161- return -ENOMEM;6262- root->fs_info->generation++;6363- atomic_set(&cur_trans->num_writers, 1);6464- cur_trans->num_joined = 0;6565- cur_trans->transid = root->fs_info->generation;6666- init_waitqueue_head(&cur_trans->writer_wait);6767- init_waitqueue_head(&cur_trans->commit_wait);6868- cur_trans->in_commit = 0;6969- cur_trans->blocked = 0;7070- atomic_set(&cur_trans->use_count, 1);7171- cur_trans->commit_done = 0;7272- cur_trans->start_time = get_seconds();7373-7474- cur_trans->delayed_refs.root = RB_ROOT;7575- cur_trans->delayed_refs.num_entries = 0;7676- cur_trans->delayed_refs.num_heads_ready = 0;7777- cur_trans->delayed_refs.num_heads = 0;7878- cur_trans->delayed_refs.flushing = 0;7979- cur_trans->delayed_refs.run_delayed_start = 0;8080- spin_lock_init(&cur_trans->delayed_refs.lock);8181-8282- INIT_LIST_HEAD(&cur_trans->pending_snapshots);8383- list_add_tail(&cur_trans->list, &root->fs_info->trans_list);8484- extent_io_tree_init(&cur_trans->dirty_pages,8585- root->fs_info->btree_inode->i_mapping);8686- spin_lock(&root->fs_info->new_trans_lock);8787- root->fs_info->running_transaction = cur_trans;8888- spin_unlock(&root->fs_info->new_trans_lock);8989- } else {6565+ if (cur_trans) {6666+ atomic_inc(&cur_trans->use_count);9067 atomic_inc(&cur_trans->num_writers);9168 cur_trans->num_joined++;6969+ spin_unlock(&root->fs_info->trans_lock);7070+ return 0;9271 }7272+ spin_unlock(&root->fs_info->trans_lock);7373+7474+ cur_trans = kmem_cache_alloc(btrfs_transaction_cachep, GFP_NOFS);7575+ if (!cur_trans)7676+ return -ENOMEM;7777+ spin_lock(&root->fs_info->trans_lock);7878+ if (root->fs_info->running_transaction) {7979+ kmem_cache_free(btrfs_transaction_cachep, cur_trans);8080+ cur_trans = root->fs_info->running_transaction;8181+ atomic_inc(&cur_trans->use_count);8282+ atomic_inc(&cur_trans->num_writers);8383+ cur_trans->num_joined++;8484+ spin_unlock(&root->fs_info->trans_lock);8585+ return 0;8686+ }8787+ atomic_set(&cur_trans->num_writers, 1);8888+ cur_trans->num_joined = 0;8989+ init_waitqueue_head(&cur_trans->writer_wait);9090+ init_waitqueue_head(&cur_trans->commit_wait);9191+ cur_trans->in_commit = 0;9292+ cur_trans->blocked = 0;9393+ /*9494+ * One for this trans handle, one so it will live on until we9595+ * commit the transaction.9696+ */9797+ atomic_set(&cur_trans->use_count, 2);9898+ cur_trans->commit_done = 0;9999+ cur_trans->start_time = get_seconds();100100+101101+ cur_trans->delayed_refs.root = RB_ROOT;102102+ cur_trans->delayed_refs.num_entries = 0;103103+ cur_trans->delayed_refs.num_heads_ready = 0;104104+ cur_trans->delayed_refs.num_heads = 0;105105+ cur_trans->delayed_refs.flushing = 0;106106+ cur_trans->delayed_refs.run_delayed_start = 0;107107+ spin_lock_init(&cur_trans->commit_lock);108108+ spin_lock_init(&cur_trans->delayed_refs.lock);109109+110110+ INIT_LIST_HEAD(&cur_trans->pending_snapshots);111111+ list_add_tail(&cur_trans->list, &root->fs_info->trans_list);112112+ extent_io_tree_init(&cur_trans->dirty_pages,113113+ root->fs_info->btree_inode->i_mapping);114114+ root->fs_info->generation++;115115+ cur_trans->transid = root->fs_info->generation;116116+ root->fs_info->running_transaction = cur_trans;117117+ spin_unlock(&root->fs_info->trans_lock);9311894119 return 0;95120}···12699 * to make sure the old root from before we joined the transaction is deleted127100 * when the transaction commits128101 */129129-static noinline int record_root_in_trans(struct btrfs_trans_handle *trans,130130- struct btrfs_root *root)102102+int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,103103+ struct btrfs_root *root)131104{132105 if (root->ref_cows && root->last_trans < trans->transid) {133106 WARN_ON(root == root->fs_info->extent_root);134107 WARN_ON(root->commit_root != root->node);135108109109+ spin_lock(&root->fs_info->fs_roots_radix_lock);110110+ if (root->last_trans == trans->transid) {111111+ spin_unlock(&root->fs_info->fs_roots_radix_lock);112112+ return 0;113113+ }114114+ root->last_trans = trans->transid;136115 radix_tree_tag_set(&root->fs_info->fs_roots_radix,137116 (unsigned long)root->root_key.objectid,138117 BTRFS_ROOT_TRANS_TAG);139139- root->last_trans = trans->transid;118118+ spin_unlock(&root->fs_info->fs_roots_radix_lock);140119 btrfs_init_reloc_root(trans, root);141120 }142142- return 0;143143-}144144-145145-int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,146146- struct btrfs_root *root)147147-{148148- if (!root->ref_cows)149149- return 0;150150-151151- mutex_lock(&root->fs_info->trans_mutex);152152- if (root->last_trans == trans->transid) {153153- mutex_unlock(&root->fs_info->trans_mutex);154154- return 0;155155- }156156-157157- record_root_in_trans(trans, root);158158- mutex_unlock(&root->fs_info->trans_mutex);159121 return 0;160122}161123···156140{157141 struct btrfs_transaction *cur_trans;158142143143+ spin_lock(&root->fs_info->trans_lock);159144 cur_trans = root->fs_info->running_transaction;160145 if (cur_trans && cur_trans->blocked) {161146 DEFINE_WAIT(wait);162147 atomic_inc(&cur_trans->use_count);148148+ spin_unlock(&root->fs_info->trans_lock);163149 while (1) {164150 prepare_to_wait(&root->fs_info->transaction_wait, &wait,165151 TASK_UNINTERRUPTIBLE);166152 if (!cur_trans->blocked)167153 break;168168- mutex_unlock(&root->fs_info->trans_mutex);169154 schedule();170170- mutex_lock(&root->fs_info->trans_mutex);171155 }172156 finish_wait(&root->fs_info->transaction_wait, &wait);173157 put_transaction(cur_trans);158158+ } else {159159+ spin_unlock(&root->fs_info->trans_lock);174160 }175161}176162···185167186168static int may_wait_transaction(struct btrfs_root *root, int type)187169{188188- if (!root->fs_info->log_root_recovering &&189189- ((type == TRANS_START && !root->fs_info->open_ioctl_trans) ||190190- type == TRANS_USERSPACE))170170+ if (root->fs_info->log_root_recovering)171171+ return 0;172172+173173+ if (type == TRANS_USERSPACE)191174 return 1;175175+176176+ if (type == TRANS_START &&177177+ !atomic_read(&root->fs_info->open_ioctl_trans))178178+ return 1;179179+192180 return 0;193181}194182···208184209185 if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR)210186 return ERR_PTR(-EROFS);187187+188188+ if (current->journal_info) {189189+ WARN_ON(type != TRANS_JOIN && type != TRANS_JOIN_NOLOCK);190190+ h = current->journal_info;191191+ h->use_count++;192192+ h->orig_rsv = h->block_rsv;193193+ h->block_rsv = NULL;194194+ goto got_it;195195+ }211196again:212197 h = kmem_cache_alloc(btrfs_trans_handle_cachep, GFP_NOFS);213198 if (!h)214199 return ERR_PTR(-ENOMEM);215200216216- if (type != TRANS_JOIN_NOLOCK)217217- mutex_lock(&root->fs_info->trans_mutex);218201 if (may_wait_transaction(root, type))219202 wait_current_trans(root);220203221221- ret = join_transaction(root);204204+ do {205205+ ret = join_transaction(root, type == TRANS_JOIN_NOLOCK);206206+ if (ret == -EBUSY)207207+ wait_current_trans(root);208208+ } while (ret == -EBUSY);209209+222210 if (ret < 0) {223211 kmem_cache_free(btrfs_trans_handle_cachep, h);224224- if (type != TRANS_JOIN_NOLOCK)225225- mutex_unlock(&root->fs_info->trans_mutex);226212 return ERR_PTR(ret);227213 }228214229215 cur_trans = root->fs_info->running_transaction;230230- atomic_inc(&cur_trans->use_count);231231- if (type != TRANS_JOIN_NOLOCK)232232- mutex_unlock(&root->fs_info->trans_mutex);233216234217 h->transid = cur_trans->transid;235218 h->transaction = cur_trans;236219 h->blocks_used = 0;237237- h->block_group = 0;238220 h->bytes_reserved = 0;239221 h->delayed_ref_updates = 0;222222+ h->use_count = 1;240223 h->block_rsv = NULL;224224+ h->orig_rsv = NULL;241225242226 smp_mb();243227 if (cur_trans->blocked && may_wait_transaction(root, type)) {···273241 }274242 }275243276276- if (type != TRANS_JOIN_NOLOCK)277277- mutex_lock(&root->fs_info->trans_mutex);278278- record_root_in_trans(h, root);279279- if (type != TRANS_JOIN_NOLOCK)280280- mutex_unlock(&root->fs_info->trans_mutex);244244+got_it:245245+ btrfs_record_root_in_trans(h, root);281246282247 if (!current->journal_info && type != TRANS_USERSPACE)283248 current->journal_info = h;···286257{287258 return start_transaction(root, num_items, TRANS_START);288259}289289-struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root,290290- int num_blocks)260260+struct btrfs_trans_handle *btrfs_join_transaction(struct btrfs_root *root)291261{292262 return start_transaction(root, 0, TRANS_JOIN);293263}294264295295-struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root,296296- int num_blocks)265265+struct btrfs_trans_handle *btrfs_join_transaction_nolock(struct btrfs_root *root)297266{298267 return start_transaction(root, 0, TRANS_JOIN_NOLOCK);299268}300269301301-struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *r,302302- int num_blocks)270270+struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root)303271{304304- return start_transaction(r, 0, TRANS_USERSPACE);272272+ return start_transaction(root, 0, TRANS_USERSPACE);305273}306274307275/* wait for a transaction commit to be fully complete */···306280 struct btrfs_transaction *commit)307281{308282 DEFINE_WAIT(wait);309309- mutex_lock(&root->fs_info->trans_mutex);310283 while (!commit->commit_done) {311284 prepare_to_wait(&commit->commit_wait, &wait,312285 TASK_UNINTERRUPTIBLE);313286 if (commit->commit_done)314287 break;315315- mutex_unlock(&root->fs_info->trans_mutex);316288 schedule();317317- mutex_lock(&root->fs_info->trans_mutex);318289 }319319- mutex_unlock(&root->fs_info->trans_mutex);320290 finish_wait(&commit->commit_wait, &wait);321291 return 0;322292}···322300 struct btrfs_transaction *cur_trans = NULL, *t;323301 int ret;324302325325- mutex_lock(&root->fs_info->trans_mutex);326326-327303 ret = 0;328304 if (transid) {329305 if (transid <= root->fs_info->last_trans_committed)330330- goto out_unlock;306306+ goto out;331307332308 /* find specified transaction */309309+ spin_lock(&root->fs_info->trans_lock);333310 list_for_each_entry(t, &root->fs_info->trans_list, list) {334311 if (t->transid == transid) {335312 cur_trans = t;313313+ atomic_inc(&cur_trans->use_count);336314 break;337315 }338316 if (t->transid > transid)339317 break;340318 }319319+ spin_unlock(&root->fs_info->trans_lock);341320 ret = -EINVAL;342321 if (!cur_trans)343343- goto out_unlock; /* bad transid */322322+ goto out; /* bad transid */344323 } else {345324 /* find newest transaction that is committing | committed */325325+ spin_lock(&root->fs_info->trans_lock);346326 list_for_each_entry_reverse(t, &root->fs_info->trans_list,347327 list) {348328 if (t->in_commit) {349329 if (t->commit_done)350350- goto out_unlock;330330+ goto out;351331 cur_trans = t;332332+ atomic_inc(&cur_trans->use_count);352333 break;353334 }354335 }336336+ spin_unlock(&root->fs_info->trans_lock);355337 if (!cur_trans)356356- goto out_unlock; /* nothing committing|committed */338338+ goto out; /* nothing committing|committed */357339 }358358-359359- atomic_inc(&cur_trans->use_count);360360- mutex_unlock(&root->fs_info->trans_mutex);361340362341 wait_for_commit(root, cur_trans);363342364364- mutex_lock(&root->fs_info->trans_mutex);365343 put_transaction(cur_trans);366344 ret = 0;367367-out_unlock:368368- mutex_unlock(&root->fs_info->trans_mutex);345345+out:369346 return ret;370347}371348372349void btrfs_throttle(struct btrfs_root *root)373350{374374- mutex_lock(&root->fs_info->trans_mutex);375375- if (!root->fs_info->open_ioctl_trans)351351+ if (!atomic_read(&root->fs_info->open_ioctl_trans))376352 wait_current_trans(root);377377- mutex_unlock(&root->fs_info->trans_mutex);378353}379354380355static int should_end_transaction(struct btrfs_trans_handle *trans,···389370 struct btrfs_transaction *cur_trans = trans->transaction;390371 int updates;391372373373+ smp_mb();392374 if (cur_trans->blocked || cur_trans->delayed_refs.flushing)393375 return 1;394376···407387 struct btrfs_transaction *cur_trans = trans->transaction;408388 struct btrfs_fs_info *info = root->fs_info;409389 int count = 0;390390+391391+ if (--trans->use_count) {392392+ trans->block_rsv = trans->orig_rsv;393393+ return 0;394394+ }410395411396 while (count < 4) {412397 unsigned long cur = trans->delayed_ref_updates;···435410436411 btrfs_trans_release_metadata(trans, root);437412438438- if (lock && !root->fs_info->open_ioctl_trans &&439439- should_end_transaction(trans, root))413413+ if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&414414+ should_end_transaction(trans, root)) {440415 trans->transaction->blocked = 1;416416+ smp_wmb();417417+ }441418442419 if (lock && cur_trans->blocked && !cur_trans->in_commit) {443420 if (throttle)···730703 */731704int btrfs_add_dead_root(struct btrfs_root *root)732705{733733- mutex_lock(&root->fs_info->trans_mutex);706706+ spin_lock(&root->fs_info->trans_lock);734707 list_add(&root->root_list, &root->fs_info->dead_roots);735735- mutex_unlock(&root->fs_info->trans_mutex);708708+ spin_unlock(&root->fs_info->trans_lock);736709 return 0;737710}738711···748721 int ret;749722 int err = 0;750723724724+ spin_lock(&fs_info->fs_roots_radix_lock);751725 while (1) {752726 ret = radix_tree_gang_lookup_tag(&fs_info->fs_roots_radix,753727 (void **)gang, 0,···761733 radix_tree_tag_clear(&fs_info->fs_roots_radix,762734 (unsigned long)root->root_key.objectid,763735 BTRFS_ROOT_TRANS_TAG);736736+ spin_unlock(&fs_info->fs_roots_radix_lock);764737765738 btrfs_free_log(trans, root);766739 btrfs_update_reloc_root(trans, root);···782753 err = btrfs_update_root(trans, fs_info->tree_root,783754 &root->root_key,784755 &root->root_item);756756+ spin_lock(&fs_info->fs_roots_radix_lock);785757 if (err)786758 break;787759 }788760 }761761+ spin_unlock(&fs_info->fs_roots_radix_lock);789762 return err;790763}791764···817786 btrfs_btree_balance_dirty(info->tree_root, nr);818787 cond_resched();819788820820- if (root->fs_info->closing || ret != -EAGAIN)789789+ if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN)821790 break;822791 }823792 root->defrag_running = 0;···882851 parent = dget_parent(dentry);883852 parent_inode = parent->d_inode;884853 parent_root = BTRFS_I(parent_inode)->root;885885- record_root_in_trans(trans, parent_root);854854+ btrfs_record_root_in_trans(trans, parent_root);886855887856 /*888857 * insert the directory item···900869 ret = btrfs_update_inode(trans, parent_root, parent_inode);901870 BUG_ON(ret);902871903903- record_root_in_trans(trans, root);872872+ btrfs_record_root_in_trans(trans, root);904873 btrfs_set_root_last_snapshot(&root->root_item, trans->transid);905874 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));906875 btrfs_check_and_init_root_item(new_root_item);···998967int btrfs_transaction_in_commit(struct btrfs_fs_info *info)999968{1000969 int ret = 0;10011001- spin_lock(&info->new_trans_lock);970970+ spin_lock(&info->trans_lock);1002971 if (info->running_transaction)1003972 ret = info->running_transaction->in_commit;10041004- spin_unlock(&info->new_trans_lock);973973+ spin_unlock(&info->trans_lock);1005974 return ret;1006975}10079761008977int btrfs_transaction_blocked(struct btrfs_fs_info *info)1009978{1010979 int ret = 0;10111011- spin_lock(&info->new_trans_lock);980980+ spin_lock(&info->trans_lock);1012981 if (info->running_transaction)1013982 ret = info->running_transaction->blocked;10141014- spin_unlock(&info->new_trans_lock);983983+ spin_unlock(&info->trans_lock);1015984 return ret;1016985}1017986···10351004 &wait);10361005 break;10371006 }10381038- mutex_unlock(&root->fs_info->trans_mutex);10391007 schedule();10401040- mutex_lock(&root->fs_info->trans_mutex);10411008 finish_wait(&root->fs_info->transaction_blocked_wait, &wait);10421009 }10431010}···10611032 &wait);10621033 break;10631034 }10641064- mutex_unlock(&root->fs_info->trans_mutex);10651035 schedule();10661066- mutex_lock(&root->fs_info->trans_mutex);10671036 finish_wait(&root->fs_info->transaction_wait,10681037 &wait);10691038 }···1099107211001073 INIT_DELAYED_WORK(&ac->work, do_async_commit);11011074 ac->root = root;11021102- ac->newtrans = btrfs_join_transaction(root, 0);10751075+ ac->newtrans = btrfs_join_transaction(root);11031076 if (IS_ERR(ac->newtrans)) {11041077 int err = PTR_ERR(ac->newtrans);11051078 kfree(ac);···11071080 }1108108111091082 /* take transaction reference */11101110- mutex_lock(&root->fs_info->trans_mutex);11111083 cur_trans = trans->transaction;11121084 atomic_inc(&cur_trans->use_count);11131113- mutex_unlock(&root->fs_info->trans_mutex);1114108511151086 btrfs_end_transaction(trans, root);11161087 schedule_delayed_work(&ac->work, 0);1117108811181089 /* wait for transaction to start and unblock */11191119- mutex_lock(&root->fs_info->trans_mutex);11201090 if (wait_for_unblock)11211091 wait_current_trans_commit_start_and_unblock(root, cur_trans);11221092 else11231093 wait_current_trans_commit_start(root, cur_trans);11241094 put_transaction(cur_trans);11251125- mutex_unlock(&root->fs_info->trans_mutex);1126109511271096 return 0;11281097}···11621139 ret = btrfs_run_delayed_refs(trans, root, 0);11631140 BUG_ON(ret);1164114111651165- mutex_lock(&root->fs_info->trans_mutex);11421142+ spin_lock(&cur_trans->commit_lock);11661143 if (cur_trans->in_commit) {11441144+ spin_unlock(&cur_trans->commit_lock);11671145 atomic_inc(&cur_trans->use_count);11681168- mutex_unlock(&root->fs_info->trans_mutex);11691146 btrfs_end_transaction(trans, root);1170114711711148 ret = wait_for_commit(root, cur_trans);11721149 BUG_ON(ret);1173115011741174- mutex_lock(&root->fs_info->trans_mutex);11751151 put_transaction(cur_trans);11761176- mutex_unlock(&root->fs_info->trans_mutex);1177115211781153 return 0;11791154 }1180115511811156 trans->transaction->in_commit = 1;11821157 trans->transaction->blocked = 1;11581158+ spin_unlock(&cur_trans->commit_lock);11831159 wake_up(&root->fs_info->transaction_blocked_wait);1184116011611161+ spin_lock(&root->fs_info->trans_lock);11851162 if (cur_trans->list.prev != &root->fs_info->trans_list) {11861163 prev_trans = list_entry(cur_trans->list.prev,11871164 struct btrfs_transaction, list);11881165 if (!prev_trans->commit_done) {11891166 atomic_inc(&prev_trans->use_count);11901190- mutex_unlock(&root->fs_info->trans_mutex);11671167+ spin_unlock(&root->fs_info->trans_lock);1191116811921169 wait_for_commit(root, prev_trans);1193117011941194- mutex_lock(&root->fs_info->trans_mutex);11951171 put_transaction(prev_trans);11721172+ } else {11731173+ spin_unlock(&root->fs_info->trans_lock);11961174 }11751175+ } else {11761176+ spin_unlock(&root->fs_info->trans_lock);11971177 }1198117811991179 if (now < cur_trans->start_time || now - cur_trans->start_time < 1)···1204117812051179 do {12061180 int snap_pending = 0;11811181+12071182 joined = cur_trans->num_joined;12081183 if (!list_empty(&trans->transaction->pending_snapshots))12091184 snap_pending = 1;1210118512111186 WARN_ON(cur_trans != trans->transaction);12121212- mutex_unlock(&root->fs_info->trans_mutex);1213118712141188 if (flush_on_commit || snap_pending) {12151189 btrfs_start_delalloc_inodes(root, 1);···12321206 prepare_to_wait(&cur_trans->writer_wait, &wait,12331207 TASK_UNINTERRUPTIBLE);1234120812351235- smp_mb();12361209 if (atomic_read(&cur_trans->num_writers) > 1)12371210 schedule_timeout(MAX_SCHEDULE_TIMEOUT);12381211 else if (should_grow)12391212 schedule_timeout(1);1240121312411241- mutex_lock(&root->fs_info->trans_mutex);12421214 finish_wait(&cur_trans->writer_wait, &wait);12151215+ spin_lock(&root->fs_info->trans_lock);12161216+ root->fs_info->trans_no_join = 1;12171217+ spin_unlock(&root->fs_info->trans_lock);12431218 } while (atomic_read(&cur_trans->num_writers) > 1 ||12441219 (should_grow && cur_trans->num_joined != joined));12451220···12851258 btrfs_prepare_extent_commit(trans, root);1286125912871260 cur_trans = root->fs_info->running_transaction;12881288- spin_lock(&root->fs_info->new_trans_lock);12891289- root->fs_info->running_transaction = NULL;12901290- spin_unlock(&root->fs_info->new_trans_lock);1291126112921262 btrfs_set_root_node(&root->fs_info->tree_root->root_item,12931263 root->fs_info->tree_root->node);···13051281 sizeof(root->fs_info->super_copy));1306128213071283 trans->transaction->blocked = 0;12841284+ spin_lock(&root->fs_info->trans_lock);12851285+ root->fs_info->running_transaction = NULL;12861286+ root->fs_info->trans_no_join = 0;12871287+ spin_unlock(&root->fs_info->trans_lock);1308128813091289 wake_up(&root->fs_info->transaction_wait);1310129013111311- mutex_unlock(&root->fs_info->trans_mutex);13121291 ret = btrfs_write_and_wait_transaction(trans, root);13131292 BUG_ON(ret);13141293 write_ctree_super(trans, root, 0);···1324129713251298 btrfs_finish_extent_commit(trans, root);1326129913271327- mutex_lock(&root->fs_info->trans_mutex);13281328-13291300 cur_trans->commit_done = 1;1330130113311302 root->fs_info->last_trans_committed = cur_trans->transid;1332130313331304 wake_up(&cur_trans->commit_wait);1334130513061306+ spin_lock(&root->fs_info->trans_lock);13351307 list_del_init(&cur_trans->list);13081308+ spin_unlock(&root->fs_info->trans_lock);13091309+13361310 put_transaction(cur_trans);13371311 put_transaction(cur_trans);1338131213391313 trace_btrfs_transaction_commit(root);13401340-13411341- mutex_unlock(&root->fs_info->trans_mutex);1342131413431315 btrfs_scrub_continue(root);13441316···13601334 LIST_HEAD(list);13611335 struct btrfs_fs_info *fs_info = root->fs_info;1362133613631363- mutex_lock(&fs_info->trans_mutex);13371337+ spin_lock(&fs_info->trans_lock);13641338 list_splice_init(&fs_info->dead_roots, &list);13651365- mutex_unlock(&fs_info->trans_mutex);13391339+ spin_unlock(&fs_info->trans_lock);1366134013671341 while (!list_empty(&list)) {13681342 root = list_entry(list.next, struct btrfs_root, root_list);
···674674 if (IS_ERR(sleb)) {675675 if (PTR_ERR(sleb) == -EUCLEAN)676676 sleb = ubifs_recover_leb(c, lnum, 0,677677- c->sbuf, 0);677677+ c->sbuf, -1);678678 if (IS_ERR(sleb)) {679679 err = PTR_ERR(sleb);680680 break;
+94-70
fs/ubifs/recovery.c
···564564}565565566566/**567567- * drop_last_node - drop the last node or group of nodes.567567+ * drop_last_group - drop the last group of nodes.568568 * @sleb: scanned LEB information569569 * @offs: offset of dropped nodes is returned here570570- * @grouped: non-zero if whole group of nodes have to be dropped571570 *572571 * This is a helper function for 'ubifs_recover_leb()' which drops the last573573- * node of the scanned LEB or the last group of nodes if @grouped is not zero.574574- * This function returns %1 if a node was dropped and %0 otherwise.572572+ * group of nodes of the scanned LEB.575573 */576576-static int drop_last_node(struct ubifs_scan_leb *sleb, int *offs, int grouped)574574+static void drop_last_group(struct ubifs_scan_leb *sleb, int *offs)577575{578578- int dropped = 0;579579-580576 while (!list_empty(&sleb->nodes)) {581577 struct ubifs_scan_node *snod;582578 struct ubifs_ch *ch;···581585 list);582586 ch = snod->node;583587 if (ch->group_type != UBIFS_IN_NODE_GROUP)584584- return dropped;585585- dbg_rcvry("dropping node at %d:%d", sleb->lnum, snod->offs);588588+ break;589589+590590+ dbg_rcvry("dropping grouped node at %d:%d",591591+ sleb->lnum, snod->offs);586592 *offs = snod->offs;587593 list_del(&snod->list);588594 kfree(snod);589595 sleb->nodes_cnt -= 1;590590- dropped = 1;591591- if (!grouped)592592- break;593596 }594594- return dropped;597597+}598598+599599+/**600600+ * drop_last_node - drop the last node.601601+ * @sleb: scanned LEB information602602+ * @offs: offset of dropped nodes is returned here603603+ * @grouped: non-zero if whole group of nodes have to be dropped604604+ *605605+ * This is a helper function for 'ubifs_recover_leb()' which drops the last606606+ * node of the scanned LEB.607607+ */608608+static void drop_last_node(struct ubifs_scan_leb *sleb, int *offs)609609+{610610+ struct ubifs_scan_node *snod;611611+612612+ if (!list_empty(&sleb->nodes)) {613613+ snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node,614614+ list);615615+616616+ dbg_rcvry("dropping last node at %d:%d", sleb->lnum, snod->offs);617617+ *offs = snod->offs;618618+ list_del(&snod->list);619619+ kfree(snod);620620+ sleb->nodes_cnt -= 1;621621+ }595622}596623597624/**···623604 * @lnum: LEB number624605 * @offs: offset625606 * @sbuf: LEB-sized buffer to use626626- * @grouped: nodes may be grouped for recovery607607+ * @jhead: journal head number this LEB belongs to (%-1 if the LEB does not608608+ * belong to any journal head)627609 *628610 * This function does a scan of a LEB, but caters for errors that might have629611 * been caused by the unclean unmount from which we are attempting to recover.···632612 * found, and a negative error code in case of failure.633613 */634614struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,635635- int offs, void *sbuf, int grouped)615615+ int offs, void *sbuf, int jhead)636616{637617 int ret = 0, err, len = c->leb_size - offs, start = offs, min_io_unit;618618+ int grouped = jhead == -1 ? 0 : c->jheads[jhead].grouped;638619 struct ubifs_scan_leb *sleb;639620 void *buf = sbuf + offs;640621641641- dbg_rcvry("%d:%d", lnum, offs);622622+ dbg_rcvry("%d:%d, jhead %d, grouped %d", lnum, offs, jhead, grouped);642623643624 sleb = ubifs_start_scan(c, lnum, offs, sbuf);644625 if (IS_ERR(sleb))···656635 * Scan quietly until there is an error from which we cannot657636 * recover658637 */659659- ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 0);638638+ ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1);660639 if (ret == SCANNED_A_NODE) {661640 /* A valid node, and not a padding node */662641 struct ubifs_ch *ch = buf;···716695 * If nodes are grouped, always drop the incomplete group at717696 * the end.718697 */719719- drop_last_node(sleb, &offs, 1);698698+ drop_last_group(sleb, &offs);720699721721- /*722722- * While we are in the middle of the same min. I/O unit keep dropping723723- * nodes. So basically, what we want is to make sure that the last min.724724- * I/O unit where we saw the corruption is dropped completely with all725725- * the uncorrupted node which may possibly sit there.726726- *727727- * In other words, let's name the min. I/O unit where the corruption728728- * starts B, and the previous min. I/O unit A. The below code tries to729729- * deal with a situation when half of B contains valid nodes or the end730730- * of a valid node, and the second half of B contains corrupted data or731731- * garbage. This means that UBIFS had been writing to B just before the732732- * power cut happened. I do not know how realistic is this scenario733733- * that half of the min. I/O unit had been written successfully and the734734- * other half not, but this is possible in our 'failure mode emulation'735735- * infrastructure at least.736736- *737737- * So what is the problem, why we need to drop those nodes? Whey can't738738- * we just clean-up the second half of B by putting a padding node739739- * there? We can, and this works fine with one exception which was740740- * reproduced with power cut emulation testing and happens extremely741741- * rarely. The description follows, but it is worth noting that that is742742- * only about the GC head, so we could do this trick only if the bud743743- * belongs to the GC head, but it does not seem to be worth an744744- * additional "if" statement.745745- *746746- * So, imagine the file-system is full, we run GC which is moving valid747747- * nodes from LEB X to LEB Y (obviously, LEB Y is the current GC head748748- * LEB). The @c->gc_lnum is -1, which means that GC will retain LEB X749749- * and will try to continue. Imagine that LEB X is currently the750750- * dirtiest LEB, and the amount of used space in LEB Y is exactly the751751- * same as amount of free space in LEB X.752752- *753753- * And a power cut happens when nodes are moved from LEB X to LEB Y. We754754- * are here trying to recover LEB Y which is the GC head LEB. We find755755- * the min. I/O unit B as described above. Then we clean-up LEB Y by756756- * padding min. I/O unit. And later 'ubifs_rcvry_gc_commit()' function757757- * fails, because it cannot find a dirty LEB which could be GC'd into758758- * LEB Y! Even LEB X does not match because the amount of valid nodes759759- * there does not fit the free space in LEB Y any more! And this is760760- * because of the padding node which we added to LEB Y. The761761- * user-visible effect of this which I once observed and analysed is762762- * that we cannot mount the file-system with -ENOSPC error.763763- *764764- * So obviously, to make sure that situation does not happen we should765765- * free min. I/O unit B in LEB Y completely and the last used min. I/O766766- * unit in LEB Y should be A. This is basically what the below code767767- * tries to do.768768- */769769- while (min_io_unit == round_down(offs, c->min_io_size) &&770770- min_io_unit != offs &&771771- drop_last_node(sleb, &offs, grouped));700700+ if (jhead == GCHD) {701701+ /*702702+ * If this LEB belongs to the GC head then while we are in the703703+ * middle of the same min. I/O unit keep dropping nodes. So704704+ * basically, what we want is to make sure that the last min.705705+ * I/O unit where we saw the corruption is dropped completely706706+ * with all the uncorrupted nodes which may possibly sit there.707707+ *708708+ * In other words, let's name the min. I/O unit where the709709+ * corruption starts B, and the previous min. I/O unit A. The710710+ * below code tries to deal with a situation when half of B711711+ * contains valid nodes or the end of a valid node, and the712712+ * second half of B contains corrupted data or garbage. This713713+ * means that UBIFS had been writing to B just before the power714714+ * cut happened. I do not know how realistic is this scenario715715+ * that half of the min. I/O unit had been written successfully716716+ * and the other half not, but this is possible in our 'failure717717+ * mode emulation' infrastructure at least.718718+ *719719+ * So what is the problem, why we need to drop those nodes? Why720720+ * can't we just clean-up the second half of B by putting a721721+ * padding node there? We can, and this works fine with one722722+ * exception which was reproduced with power cut emulation723723+ * testing and happens extremely rarely.724724+ *725725+ * Imagine the file-system is full, we run GC which starts726726+ * moving valid nodes from LEB X to LEB Y (obviously, LEB Y is727727+ * the current GC head LEB). The @c->gc_lnum is -1, which means728728+ * that GC will retain LEB X and will try to continue. Imagine729729+ * that LEB X is currently the dirtiest LEB, and the amount of730730+ * used space in LEB Y is exactly the same as amount of free731731+ * space in LEB X.732732+ *733733+ * And a power cut happens when nodes are moved from LEB X to734734+ * LEB Y. We are here trying to recover LEB Y which is the GC735735+ * head LEB. We find the min. I/O unit B as described above.736736+ * Then we clean-up LEB Y by padding min. I/O unit. And later737737+ * 'ubifs_rcvry_gc_commit()' function fails, because it cannot738738+ * find a dirty LEB which could be GC'd into LEB Y! Even LEB X739739+ * does not match because the amount of valid nodes there does740740+ * not fit the free space in LEB Y any more! And this is741741+ * because of the padding node which we added to LEB Y. The742742+ * user-visible effect of this which I once observed and743743+ * analysed is that we cannot mount the file-system with744744+ * -ENOSPC error.745745+ *746746+ * So obviously, to make sure that situation does not happen we747747+ * should free min. I/O unit B in LEB Y completely and the last748748+ * used min. I/O unit in LEB Y should be A. This is basically749749+ * what the below code tries to do.750750+ */751751+ while (offs > min_io_unit)752752+ drop_last_node(sleb, &offs);753753+ }772754773755 buf = sbuf + offs;774756 len = c->leb_size - offs;···905881 }906882 ubifs_scan_destroy(sleb);907883 }908908- return ubifs_recover_leb(c, lnum, offs, sbuf, 0);884884+ return ubifs_recover_leb(c, lnum, offs, sbuf, -1);909885}910886911887/**
+1-2
fs/ubifs/replay.c
···557557 * these LEBs could possibly be written to at the power cut558558 * time.559559 */560560- sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf,561561- b->bud->jhead != GCHD);560560+ sleb = ubifs_recover_leb(c, lnum, offs, c->sbuf, b->bud->jhead);562561 else563562 sleb = ubifs_scan(c, lnum, offs, c->sbuf, 0);564563 if (IS_ERR(sleb))
+5-1
fs/ubifs/shrinker.c
···284284 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt);285285286286 if (nr == 0)287287- return clean_zn_cnt;287287+ /*288288+ * Due to the way UBIFS updates the clean znode counter it may289289+ * temporarily be negative.290290+ */291291+ return clean_zn_cnt >= 0 ? clean_zn_cnt : 1;288292289293 if (!clean_zn_cnt) {290294 /*
+24-18
fs/ubifs/super.c
···811811812812 c->jheads[i].wbuf.sync_callback = &bud_wbuf_callback;813813 c->jheads[i].wbuf.jhead = i;814814+ c->jheads[i].grouped = 1;814815 }815816816817 c->jheads[BASEHD].wbuf.dtype = UBI_SHORTTERM;817818 /*818819 * Garbage Collector head likely contains long-term data and819819- * does not need to be synchronized by timer.820820+ * does not need to be synchronized by timer. Also GC head nodes are821821+ * not grouped.820822 */821823 c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM;822824 c->jheads[GCHD].wbuf.no_timer = 1;825825+ c->jheads[GCHD].grouped = 0;823826824827 return 0;825828}···12871284 if ((c->mst_node->flags & cpu_to_le32(UBIFS_MST_DIRTY)) != 0) {12881285 ubifs_msg("recovery needed");12891286 c->need_recovery = 1;12901290- if (!c->ro_mount) {12911291- err = ubifs_recover_inl_heads(c, c->sbuf);12921292- if (err)12931293- goto out_master;12941294- }12951295- } else if (!c->ro_mount) {12871287+ }12881288+12891289+ if (c->need_recovery && !c->ro_mount) {12901290+ err = ubifs_recover_inl_heads(c, c->sbuf);12911291+ if (err)12921292+ goto out_master;12931293+ }12941294+12951295+ err = ubifs_lpt_init(c, 1, !c->ro_mount);12961296+ if (err)12971297+ goto out_master;12981298+12991299+ if (!c->ro_mount && c->space_fixup) {13001300+ err = ubifs_fixup_free_space(c);13011301+ if (err)13021302+ goto out_master;13031303+ }13041304+13051305+ if (!c->ro_mount) {12961306 /*12971307 * Set the "dirty" flag so that if we reboot uncleanly we12981308 * will notice this immediately on the next mount.···13131297 c->mst_node->flags |= cpu_to_le32(UBIFS_MST_DIRTY);13141298 err = ubifs_write_master(c);13151299 if (err)13161316- goto out_master;13001300+ goto out_lpt;13171301 }13181318-13191319- err = ubifs_lpt_init(c, 1, !c->ro_mount);13201320- if (err)13211321- goto out_lpt;1322130213231303 err = dbg_check_idx_size(c, c->bi.old_idx_sz);13241304 if (err)···14071395 }14081396 } else14091397 ubifs_assert(c->lst.taken_empty_lebs > 0);14101410-14111411- if (!c->ro_mount && c->space_fixup) {14121412- err = ubifs_fixup_free_space(c);14131413- if (err)14141414- goto out_infos;14151415- }1416139814171399 err = dbg_check_filesystem(c);14181400 if (err)
+5-4
fs/ubifs/tnc.c
···28762876 */28772877void ubifs_tnc_close(struct ubifs_info *c)28782878{28792879- long clean_freed;28802880-28812879 tnc_destroy_cnext(c);28822880 if (c->zroot.znode) {28832883- clean_freed = ubifs_destroy_tnc_subtree(c->zroot.znode);28842884- atomic_long_sub(clean_freed, &ubifs_clean_zn_cnt);28812881+ long n;28822882+28832883+ ubifs_destroy_tnc_subtree(c->zroot.znode);28842884+ n = atomic_long_read(&c->clean_zn_cnt);28852885+ atomic_long_sub(n, &ubifs_clean_zn_cnt);28852886 }28862887 kfree(c->gap_lebs);28872888 kfree(c->ilebs);
+3-1
fs/ubifs/ubifs.h
···722722 * struct ubifs_jhead - journal head.723723 * @wbuf: head's write-buffer724724 * @buds_list: list of bud LEBs belonging to this journal head725725+ * @grouped: non-zero if UBIFS groups nodes when writing to this journal head725726 *726727 * Note, the @buds list is protected by the @c->buds_lock.727728 */728729struct ubifs_jhead {729730 struct ubifs_wbuf wbuf;730731 struct list_head buds_list;732732+ unsigned int grouped:1;731733};732734733735/**···17441742int ubifs_recover_master_node(struct ubifs_info *c);17451743int ubifs_write_rcvrd_mst_node(struct ubifs_info *c);17461744struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,17471747- int offs, void *sbuf, int grouped);17451745+ int offs, void *sbuf, int jhead);17481746struct ubifs_scan_leb *ubifs_recover_log_leb(struct ubifs_info *c, int lnum,17491747 int offs, void *sbuf);17501748int ubifs_recover_inl_heads(const struct ubifs_info *c, void *sbuf);
+3-1
include/asm-generic/unistd.h
···683683__SYSCALL(__NR_syncfs, sys_syncfs)684684#define __NR_setns 268685685__SYSCALL(__NR_setns, sys_setns)686686+#define __NR_sendmmsg 269687687+__SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg)686688687689#undef __NR_syscalls688688-#define __NR_syscalls 269690690+#define __NR_syscalls 270689691690692/*691693 * All syscalls below here should go away really,
+2-2
include/linux/blkdev.h
···12821282#define blk_get_integrity(a) (0)12831283#define blk_integrity_compare(a, b) (0)12841284#define blk_integrity_register(a, b) (0)12851285-#define blk_integrity_unregister(a) do { } while (0);12861286-#define blk_queue_max_integrity_segments(a, b) do { } while (0);12851285+#define blk_integrity_unregister(a) do { } while (0)12861286+#define blk_queue_max_integrity_segments(a, b) do { } while (0)12871287#define queue_max_integrity_segments(a) (0)12881288#define blk_integrity_merge_rq(a, b, c) (0)12891289#define blk_integrity_merge_bio(a, b, c) (0)
···100100 sector_t start_sect;101101 sector_t nr_sects;102102 sector_t alignment_offset;103103+ unsigned int discard_alignment;103104 struct device __dev;104105 struct kobject *holder_dir;105106 int policy, partno;
+6-2
include/linux/ieee80211.h
···10031003#define WLAN_CAPABILITY_ESS (1<<0)10041004#define WLAN_CAPABILITY_IBSS (1<<1)1005100510061006-/* A mesh STA sets the ESS and IBSS capability bits to zero */10071007-#define WLAN_CAPABILITY_IS_MBSS(cap) \10061006+/*10071007+ * A mesh STA sets the ESS and IBSS capability bits to zero.10081008+ * however, this holds true for p2p probe responses (in the p2p_find10091009+ * phase) as well.10101010+ */10111011+#define WLAN_CAPABILITY_IS_STA_BSS(cap) \10081012 (!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))1009101310101014#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
+1
include/linux/if_packet.h
···7070#define TP_STATUS_COPY 0x27171#define TP_STATUS_LOSING 0x47272#define TP_STATUS_CSUMNOTREADY 0x87373+#define TP_STATUS_VLAN_VALID 0x10 /* auxdata has valid tp_vlan_tci */73747475/* Tx ring - header status */7576#define TP_STATUS_AVAILABLE 0x0
+1
include/linux/mtd/physmap.h
···1919#include <linux/mtd/partitions.h>20202121struct map_info;2222+struct platform_device;22232324struct physmap_flash_data {2425 unsigned int width;
+4-5
include/linux/tty_ldisc.h
···7676 * tty device. It is solely the responsibility of the line7777 * discipline to handle poll requests.7878 *7979- * unsigned int (*receive_buf)(struct tty_struct *, const unsigned char *cp,7979+ * void (*receive_buf)(struct tty_struct *, const unsigned char *cp,8080 * char *fp, int count);8181 *8282 * This function is called by the low-level tty driver to send···8484 * processing. <cp> is a pointer to the buffer of input8585 * character received by the device. <fp> is a pointer to a8686 * pointer of flag bytes which indicate whether a character was8787- * received with a parity error, etc. Returns the amount of bytes8888- * received.8787+ * received with a parity error, etc.8988 * 9089 * void (*write_wakeup)(struct tty_struct *);9190 *···140141 /*141142 * The following routines are called from below.142143 */143143- unsigned int (*receive_buf)(struct tty_struct *,144144- const unsigned char *cp, char *fp, int count);144144+ void (*receive_buf)(struct tty_struct *, const unsigned char *cp,145145+ char *fp, int count);145146 void (*write_wakeup)(struct tty_struct *);146147 void (*dcd_change)(struct tty_struct *, unsigned int,147148 struct pps_event_time *);
+9
include/linux/virtio.h
···5151 * This re-enables callbacks; it returns "false" if there are pending5252 * buffers in the queue, to detect a possible race between the driver5353 * checking for more work, and enabling callbacks.5454+ * virtqueue_enable_cb_delayed: restart callbacks after disable_cb.5555+ * vq: the struct virtqueue we're talking about.5656+ * This re-enables callbacks but hints to the other side to delay5757+ * interrupts until most of the available buffers have been processed;5858+ * it returns "false" if there are many pending buffers in the queue,5959+ * to detect a possible race between the driver checking for more work,6060+ * and enabling callbacks.5461 * virtqueue_detach_unused_buf: detach first unused buffer5562 * vq: the struct virtqueue we're talking about.5663 * Returns NULL or the "data" token handed to add_buf···9285void virtqueue_disable_cb(struct virtqueue *vq);93869487bool virtqueue_enable_cb(struct virtqueue *vq);8888+8989+bool virtqueue_enable_cb_delayed(struct virtqueue *vq);95909691void *virtqueue_detach_unused_buf(struct virtqueue *vq);9792
+24-1
include/linux/virtio_9p.h
···11#ifndef _LINUX_VIRTIO_9P_H22#define _LINUX_VIRTIO_9P_H33/* This header is BSD licensed so anyone can use the definitions to implement44- * compatible drivers/servers. */44+ * compatible drivers/servers.55+ *66+ * Redistribution and use in source and binary forms, with or without77+ * modification, are permitted provided that the following conditions88+ * are met:99+ * 1. Redistributions of source code must retain the above copyright1010+ * notice, this list of conditions and the following disclaimer.1111+ * 2. Redistributions in binary form must reproduce the above copyright1212+ * notice, this list of conditions and the following disclaimer in the1313+ * documentation and/or other materials provided with the distribution.1414+ * 3. Neither the name of IBM nor the names of its contributors1515+ * may be used to endorse or promote products derived from this software1616+ * without specific prior written permission.1717+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2020+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF2727+ * SUCH DAMAGE. */528#include <linux/types.h>629#include <linux/virtio_ids.h>730#include <linux/virtio_config.h>
+24-1
include/linux/virtio_balloon.h
···11#ifndef _LINUX_VIRTIO_BALLOON_H22#define _LINUX_VIRTIO_BALLOON_H33/* This header is BSD licensed so anyone can use the definitions to implement44- * compatible drivers/servers. */44+ * compatible drivers/servers.55+ *66+ * Redistribution and use in source and binary forms, with or without77+ * modification, are permitted provided that the following conditions88+ * are met:99+ * 1. Redistributions of source code must retain the above copyright1010+ * notice, this list of conditions and the following disclaimer.1111+ * 2. Redistributions in binary form must reproduce the above copyright1212+ * notice, this list of conditions and the following disclaimer in the1313+ * documentation and/or other materials provided with the distribution.1414+ * 3. Neither the name of IBM nor the names of its contributors1515+ * may be used to endorse or promote products derived from this software1616+ * without specific prior written permission.1717+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2020+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF2727+ * SUCH DAMAGE. */528#include <linux/virtio_ids.h>629#include <linux/virtio_config.h>730
+24-1
include/linux/virtio_blk.h
···11#ifndef _LINUX_VIRTIO_BLK_H22#define _LINUX_VIRTIO_BLK_H33/* This header is BSD licensed so anyone can use the definitions to implement44- * compatible drivers/servers. */44+ * compatible drivers/servers.55+ *66+ * Redistribution and use in source and binary forms, with or without77+ * modification, are permitted provided that the following conditions88+ * are met:99+ * 1. Redistributions of source code must retain the above copyright1010+ * notice, this list of conditions and the following disclaimer.1111+ * 2. Redistributions in binary form must reproduce the above copyright1212+ * notice, this list of conditions and the following disclaimer in the1313+ * documentation and/or other materials provided with the distribution.1414+ * 3. Neither the name of IBM nor the names of its contributors1515+ * may be used to endorse or promote products derived from this software1616+ * without specific prior written permission.1717+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2020+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF2727+ * SUCH DAMAGE. */528#include <linux/types.h>629#include <linux/virtio_ids.h>730#include <linux/virtio_config.h>
+24-1
include/linux/virtio_config.h
···11#ifndef _LINUX_VIRTIO_CONFIG_H22#define _LINUX_VIRTIO_CONFIG_H33/* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so44- * anyone can use the definitions to implement compatible drivers/servers. */44+ * anyone can use the definitions to implement compatible drivers/servers.55+ *66+ * Redistribution and use in source and binary forms, with or without77+ * modification, are permitted provided that the following conditions88+ * are met:99+ * 1. Redistributions of source code must retain the above copyright1010+ * notice, this list of conditions and the following disclaimer.1111+ * 2. Redistributions in binary form must reproduce the above copyright1212+ * notice, this list of conditions and the following disclaimer in the1313+ * documentation and/or other materials provided with the distribution.1414+ * 3. Neither the name of IBM nor the names of its contributors1515+ * may be used to endorse or promote products derived from this software1616+ * without specific prior written permission.1717+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2020+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF2727+ * SUCH DAMAGE. */528629/* Virtio devices use a standardized configuration space to define their730 * features and pass configuration information, but each implementation can
+25-1
include/linux/virtio_console.h
···55#include <linux/virtio_config.h>66/*77 * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so88- * anyone can use the definitions to implement compatible drivers/servers.88+ * anyone can use the definitions to implement compatible drivers/servers:99+ *1010+ *1111+ * Redistribution and use in source and binary forms, with or without1212+ * modification, are permitted provided that the following conditions1313+ * are met:1414+ * 1. Redistributions of source code must retain the above copyright1515+ * notice, this list of conditions and the following disclaimer.1616+ * 2. Redistributions in binary form must reproduce the above copyright1717+ * notice, this list of conditions and the following disclaimer in the1818+ * documentation and/or other materials provided with the distribution.1919+ * 3. Neither the name of IBM nor the names of its contributors2020+ * may be used to endorse or promote products derived from this software2121+ * without specific prior written permission.2222+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND2323+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2424+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2525+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2626+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2727+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2828+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2929+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT3030+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY3131+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF3232+ * SUCH DAMAGE.933 *1034 * Copyright (C) Red Hat, Inc., 2009, 2010, 20111135 * Copyright (C) Amit Shah <amit.shah@redhat.com>, 2009, 2010, 2011
+23-1
include/linux/virtio_ids.h
···55 *66 * This header is BSD licensed so anyone can use the definitions to implement77 * compatible drivers/servers.88- */88+ *99+ * Redistribution and use in source and binary forms, with or without1010+ * modification, are permitted provided that the following conditions1111+ * are met:1212+ * 1. Redistributions of source code must retain the above copyright1313+ * notice, this list of conditions and the following disclaimer.1414+ * 2. Redistributions in binary form must reproduce the above copyright1515+ * notice, this list of conditions and the following disclaimer in the1616+ * documentation and/or other materials provided with the distribution.1717+ * 3. Neither the name of IBM nor the names of its contributors1818+ * may be used to endorse or promote products derived from this software1919+ * without specific prior written permission.2020+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND2121+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2222+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2323+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2424+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2525+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2626+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2727+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2828+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2929+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF3030+ * SUCH DAMAGE. */9311032#define VIRTIO_ID_NET 1 /* virtio net */1133#define VIRTIO_ID_BLOCK 2 /* virtio block */
+24-1
include/linux/virtio_net.h
···11#ifndef _LINUX_VIRTIO_NET_H22#define _LINUX_VIRTIO_NET_H33/* This header is BSD licensed so anyone can use the definitions to implement44- * compatible drivers/servers. */44+ * compatible drivers/servers.55+ *66+ * Redistribution and use in source and binary forms, with or without77+ * modification, are permitted provided that the following conditions88+ * are met:99+ * 1. Redistributions of source code must retain the above copyright1010+ * notice, this list of conditions and the following disclaimer.1111+ * 2. Redistributions in binary form must reproduce the above copyright1212+ * notice, this list of conditions and the following disclaimer in the1313+ * documentation and/or other materials provided with the distribution.1414+ * 3. Neither the name of IBM nor the names of its contributors1515+ * may be used to endorse or promote products derived from this software1616+ * without specific prior written permission.1717+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND1818+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE1919+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2020+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2121+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2222+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2323+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2424+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2525+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY2626+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF2727+ * SUCH DAMAGE. */528#include <linux/types.h>629#include <linux/virtio_ids.h>730#include <linux/virtio_config.h>
+23
include/linux/virtio_pci.h
···1111 *1212 * This header is BSD licensed so anyone can use the definitions to implement1313 * compatible drivers/servers.1414+ *1515+ * Redistribution and use in source and binary forms, with or without1616+ * modification, are permitted provided that the following conditions1717+ * are met:1818+ * 1. Redistributions of source code must retain the above copyright1919+ * notice, this list of conditions and the following disclaimer.2020+ * 2. Redistributions in binary form must reproduce the above copyright2121+ * notice, this list of conditions and the following disclaimer in the2222+ * documentation and/or other materials provided with the distribution.2323+ * 3. Neither the name of IBM nor the names of its contributors2424+ * may be used to endorse or promote products derived from this software2525+ * without specific prior written permission.2626+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND2727+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2828+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2929+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE3030+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL3131+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS3232+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)3333+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT3434+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY3535+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF3636+ * SUCH DAMAGE.1437 */15381639#ifndef _LINUX_VIRTIO_PCI_H
+51-1
include/linux/virtio_ring.h
···77 * This header is BSD licensed so anyone can use the definitions to implement88 * compatible drivers/servers.99 *1010+ * Redistribution and use in source and binary forms, with or without1111+ * modification, are permitted provided that the following conditions1212+ * are met:1313+ * 1. Redistributions of source code must retain the above copyright1414+ * notice, this list of conditions and the following disclaimer.1515+ * 2. Redistributions in binary form must reproduce the above copyright1616+ * notice, this list of conditions and the following disclaimer in the1717+ * documentation and/or other materials provided with the distribution.1818+ * 3. Neither the name of IBM nor the names of its contributors1919+ * may be used to endorse or promote products derived from this software2020+ * without specific prior written permission.2121+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND2222+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE2323+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE2424+ * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE2525+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL2626+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS2727+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)2828+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT2929+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY3030+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF3131+ * SUCH DAMAGE.3232+ *1033 * Copyright Rusty Russell IBM Corporation 2007. */1134#include <linux/types.h>1235···51285229/* We support indirect buffer descriptors */5330#define VIRTIO_RING_F_INDIRECT_DESC 283131+3232+/* The Guest publishes the used index for which it expects an interrupt3333+ * at the end of the avail ring. Host should ignore the avail->flags field. */3434+/* The Host publishes the avail index for which it expects a kick3535+ * at the end of the used ring. Guest should ignore the used->flags field. */3636+#define VIRTIO_RING_F_EVENT_IDX 2954375538/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */5639struct vring_desc {···11283 * __u16 avail_flags;11384 * __u16 avail_idx;11485 * __u16 available[num];8686+ * __u16 used_event_idx;11587 *11688 * // Padding to the next align boundary.11789 * char pad[];···12191 * __u16 used_flags;12292 * __u16 used_idx;12393 * struct vring_used_elem used[num];9494+ * __u16 avail_event_idx;12495 * };12596 */9797+/* We publish the used event index at the end of the available ring, and vice9898+ * versa. They are at the end for backwards compatibility. */9999+#define vring_used_event(vr) ((vr)->avail->ring[(vr)->num])100100+#define vring_avail_event(vr) (*(__u16 *)&(vr)->used->ring[(vr)->num])101101+126102static inline void vring_init(struct vring *vr, unsigned int num, void *p,127103 unsigned long align)128104{···143107{144108 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)145109 + align - 1) & ~(align - 1))146146- + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num;110110+ + sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;111111+}112112+113113+/* The following is used with USED_EVENT_IDX and AVAIL_EVENT_IDX */114114+/* Assuming a given event_idx value from the other size, if115115+ * we have just incremented index from old to new_idx,116116+ * should we trigger an event? */117117+static inline int vring_need_event(__u16 event_idx, __u16 new_idx, __u16 old)118118+{119119+ /* Note: Xen has similar logic for notification hold-off120120+ * in include/xen/interface/io/ring.h with req_event and req_prod121121+ * corresponding to event_idx + 1 and new_idx respectively.122122+ * Note also that req_event and req_prod in Xen start at 1,123123+ * event indexes in virtio start at 0. */124124+ return (__u16)(new_idx - event_idx - 1) < (__u16)(new_idx - old);147125}148126149127#ifdef __KERNEL__
+1
include/net/sctp/command.h
···107107 SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */108108 SCTP_CMD_SEND_MSG, /* Send the whole use message */109109 SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */110110+ SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/110111 SCTP_CMD_LAST111112} sctp_verb_t;112113
+1-1
include/net/sctp/structs.h
···19931993struct sctp_chunk *sctp_assoc_lookup_asconf_ack(19941994 const struct sctp_association *asoc,19951995 __be32 serial);19961996-19961996+void sctp_asconf_queue_teardown(struct sctp_association *asoc);1997199719981998int sctp_cmp_addr_exact(const union sctp_addr *ss1,19991999 const union sctp_addr *ss2);
···697697 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT698698 depends on BUG699699 depends on ARM || AVR32 || M32R || M68K || SPARC32 || SPARC64 || \700700- FRV || SUPERH || GENERIC_BUG || BLACKFIN || MN10300700700+ FRV || SUPERH || GENERIC_BUG || BLACKFIN || MN10300 || TILE701701 default y702702 help703703 Say Y here to make BUG() panics output the file name and line number
···2247224722482248 if (should_fail_alloc_page(gfp_mask, order))22492249 return NULL;22502250-#ifndef CONFIG_ZONE_DMA22512251- if (WARN_ON_ONCE(gfp_mask & __GFP_DMA))22522252- return NULL;22532253-#endif2254225022552251 /*22562252 * Check the zones suitable for the gfp_mask contain at least one
···906906 if (c->psm == psm) {907907 /* Exact match. */908908 if (!bacmp(&bt_sk(sk)->src, src)) {909909- read_unlock_bh(&chan_list_lock);909909+ read_unlock(&chan_list_lock);910910 return c;911911 }912912
+3-6
net/caif/chnl_net.c
···139139 struct chnl_net *dev = NULL;140140 struct list_head *list_node;141141 struct list_head *_tmp;142142- /* May be called with or without RTNL lock held */143143- int islocked = rtnl_is_locked();144144- if (!islocked)145145- rtnl_lock();142142+143143+ rtnl_lock();146144 list_for_each_safe(list_node, _tmp, &chnl_net_list) {147145 dev = list_entry(list_node, struct chnl_net, list_field);148146 if (dev->state == CAIF_SHUTDOWN)149147 dev_close(dev->netdev);150148 }151151- if (!islocked)152152- rtnl_unlock();149149+ rtnl_unlock();153150}154151static DECLARE_WORK(close_worker, close_work);155152
+5-2
net/core/dev.c
···20962096{20972097 const struct net_device_ops *ops = dev->netdev_ops;20982098 int rc = NETDEV_TX_OK;20992099+ unsigned int skb_len;2099210021002101 if (likely(!skb->next)) {21012102 u32 features;···21472146 }21482147 }2149214821492149+ skb_len = skb->len;21502150 rc = ops->ndo_start_xmit(skb, dev);21512151- trace_net_dev_xmit(skb, rc);21512151+ trace_net_dev_xmit(skb, rc, dev, skb_len);21522152 if (rc == NETDEV_TX_OK)21532153 txq_trans_update(txq);21542154 return rc;···21692167 if (dev->priv_flags & IFF_XMIT_DST_RELEASE)21702168 skb_dst_drop(nskb);2171216921702170+ skb_len = nskb->len;21722171 rc = ops->ndo_start_xmit(nskb, dev);21732173- trace_net_dev_xmit(nskb, rc);21722172+ trace_net_dev_xmit(nskb, rc, dev, skb_len);21742173 if (unlikely(rc != NETDEV_TX_OK)) {21752174 if (rc & ~NETDEV_TX_MASK)21762175 goto out_kfree_gso_skb;
+3
net/ipv4/af_inet.c
···465465 if (addr_len < sizeof(struct sockaddr_in))466466 goto out;467467468468+ if (addr->sin_family != AF_INET)469469+ goto out;470470+468471 chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);469472470473 /* Not specified by any standard per-se, however it breaks too
···403403static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)404404{405405 int err, reg;406406- int val[] = {0x200c, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};406406+ int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};407407408408 for (reg = 0; reg < ARRAY_SIZE(val); reg++) {409409 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
+4-4
tools/testing/ktest/ktest.pl
···788788789789sub reboot_to {790790 if ($reboot_type eq "grub") {791791- run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch; reboot)'";791791+ run_ssh "'(echo \"savedefault --default=$grub_number --once\" | grub --batch && reboot)'";792792 return;793793 }794794···14801480 or dodie "Failed to read $config";1481148114821482 while (<IN>) {14831483- if (/^(.*?(CONFIG\S*)(=.*| is not set))/) {14831483+ if (/^((CONFIG\S*)=.*)/) {14841484 $config_ignore{$2} = $1;14851485 }14861486 }···16381638 if (!$found) {16391639 # try the other half16401640 doprint "Top half produced no set configs, trying bottom half\n";16411641- @tophalf = @start_list[$half .. $#start_list];16411641+ @tophalf = @start_list[$half + 1 .. $#start_list];16421642 create_config @tophalf;16431643 read_current_config \%current_config;16441644 foreach my $config (@tophalf) {···16901690 # remove half the configs we are looking at and see if16911691 # they are good.16921692 $half = int($#start_list / 2);16931693- } while ($half > 0);16931693+ } while ($#start_list > 0);1694169416951695 # we found a single config, try it again unless we are running manually16961696
+17-2
tools/virtio/virtio_test.c
···198198 .val = 'h',199199 },200200 {201201+ .name = "event-idx",202202+ .val = 'E',203203+ },204204+ {205205+ .name = "no-event-idx",206206+ .val = 'e',207207+ },208208+ {201209 .name = "indirect",202210 .val = 'I',203211 },···219211220212static void help()221213{222222- fprintf(stderr, "Usage: virtio_test [--help] [--no-indirect]\n");214214+ fprintf(stderr, "Usage: virtio_test [--help]"215215+ " [--no-indirect]"216216+ " [--no-event-idx]"217217+ "\n");223218}224219225220int main(int argc, char **argv)226221{227222 struct vdev_info dev;228228- unsigned long long features = 1ULL << VIRTIO_RING_F_INDIRECT_DESC;223223+ unsigned long long features = (1ULL << VIRTIO_RING_F_INDIRECT_DESC) |224224+ (1ULL << VIRTIO_RING_F_EVENT_IDX);229225 int o;230226231227 for (;;) {···240228 case '?':241229 help();242230 exit(2);231231+ case 'e':232232+ features &= ~(1ULL << VIRTIO_RING_F_EVENT_IDX);233233+ break;243234 case 'h':244235 help();245236 goto done;