Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 97213
b: refs/heads/master
c: ecc240f
h: refs/heads/master
i:
  97211: dc900f8
v: v3
  • Loading branch information
Geoff Levand authored and Paul Mackerras committed May 23, 2008
1 parent 794ab8c commit eb9ac48
Show file tree
Hide file tree
Showing 25 changed files with 129 additions and 168 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6483d152acffb83442b90dad1517fde8a7b1e12d
refs/heads/master: ecc240f90bce23651f9866a1523ba55faa89f009
25 changes: 0 additions & 25 deletions trunk/Documentation/DocBook/kernel-locking.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -703,31 +703,6 @@
</sect1>
</chapter>

<chapter id="trylock-functions">
<title>The trylock Functions</title>
<para>
There are functions that try to acquire a lock only once and immediately
return a value telling about success or failure to acquire the lock.
They can be used if you need no access to the data protected with the lock
when some other thread is holding the lock. You should acquire the lock
later if you then need access to the data protected with the lock.
</para>

<para>
<function>spin_trylock()</function> does not spin but returns non-zero if
it acquires the spinlock on the first try or 0 if not. This function can
be used in all contexts like <function>spin_lock</function>: you must have
disabled the contexts that might interrupt you and acquire the spin lock.
</para>

<para>
<function>mutex_trylock()</function> does not suspend your task
but returns non-zero if it could lock the mutex on the first try
or 0 if not. This function cannot be safely used in hardware or software
interrupt contexts despite not sleeping.
</para>
</chapter>

<chapter id="Examples">
<title>Common Examples</title>
<para>
Expand Down
3 changes: 3 additions & 0 deletions trunk/arch/powerpc/platforms/ps3/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ static int __init ps3_mm_add_memory(void)
return result;
}

lmb_add(start_addr, map.r1.size);
lmb_analyze();

result = online_pages(start_pfn, nr_pages);

if (result)
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/boot/printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static char *number(char *str, long num, int base, int size, int precision,
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return NULL;
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/acpi/dispatcher/dsmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ acpi_ds_terminate_control_method(union acpi_operand_object *method_desc,

acpi_os_release_mutex(method_desc->method.
mutex->mutex.os_mutex);
method_desc->method.mutex->mutex.thread_id = NULL;
method_desc->method.mutex->mutex.thread_id = 0;
}
}

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/acpi/executer/exmutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ acpi_status acpi_ex_release_mutex_object(union acpi_operand_object *obj_desc)

/* Clear mutex info */

obj_desc->mutex.thread_id = NULL;
obj_desc->mutex.thread_id = 0;
return_ACPI_STATUS(status);
}

Expand Down Expand Up @@ -463,7 +463,7 @@ void acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
/* Mark mutex unowned */

obj_desc->mutex.owner_thread = NULL;
obj_desc->mutex.thread_id = NULL;
obj_desc->mutex.thread_id = 0;

/* Update Thread sync_level (Last mutex is the important one) */

Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/isdn/hysdn/hycapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ static int hycapi_read_proc(char *page, char **start, off_t off,
default: s = "???"; break;
}
len += sprintf(page+len, "%-16s %s\n", "type", s);
if ((s = cinfo->version[VER_DRIVER]) != NULL)
if ((s = cinfo->version[VER_DRIVER]) != 0)
len += sprintf(page+len, "%-16s %s\n", "ver_driver", s);
if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
if ((s = cinfo->version[VER_CARDTYPE]) != 0)
len += sprintf(page+len, "%-16s %s\n", "ver_cardtype", s);
if ((s = cinfo->version[VER_SERIAL]) != NULL)
if ((s = cinfo->version[VER_SERIAL]) != 0)
len += sprintf(page+len, "%-16s %s\n", "ver_serial", s);

len += sprintf(page+len, "%-16s %s\n", "cardname", cinfo->cardname);
Expand Down
6 changes: 3 additions & 3 deletions trunk/drivers/scsi/3w-9xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
error = 0;
/* Check for command packet errors */
if (full_command_packet->command.newcommand.status != 0) {
if (tw_dev->srb[request_id] != NULL) {
if (tw_dev->srb[request_id] != 0) {
error = twa_fill_sense(tw_dev, request_id, 1, 1);
} else {
/* Skip ioctl error prints */
Expand All @@ -1290,15 +1290,15 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)

/* Check for correct state */
if (tw_dev->state[request_id] != TW_S_POSTED) {
if (tw_dev->srb[request_id] != NULL) {
if (tw_dev->srb[request_id] != 0) {
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1a, "Received a request id that wasn't posted");
TW_CLEAR_ALL_INTERRUPTS(tw_dev);
goto twa_interrupt_bail;
}
}

/* Check for internal command completion */
if (tw_dev->srb[request_id] == NULL) {
if (tw_dev->srb[request_id] == 0) {
if (request_id != tw_dev->chrdev_request_id) {
if (twa_aen_complete(tw_dev, request_id))
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1b, "Error completing AEN during attention interrupt");
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/scsi/aha152x.c
Original file line number Diff line number Diff line change
Expand Up @@ -3582,7 +3582,7 @@ static int checksetup(struct aha152x_setup *setup)
if (i == ARRAY_SIZE(ports))
return 0;

if (!request_region(setup->io_port, IO_RANGE, "aha152x")) {
if ( request_region(setup->io_port, IO_RANGE, "aha152x")==0 ) {
printk(KERN_ERR "aha152x: io port 0x%x busy.\n", setup->io_port);
return 0;
}
Expand Down Expand Up @@ -3842,7 +3842,7 @@ static int __init aha152x_init(void)
if ((setup_count == 1) && (setup[0].io_port == ports[i]))
continue;

if (!request_region(ports[i], IO_RANGE, "aha152x")) {
if ( request_region(ports[i], IO_RANGE, "aha152x")==0 ) {
printk(KERN_ERR "aha152x: io port 0x%x busy.\n", ports[i]);
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/atp870u.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ static void send_s870(struct atp_unit *dev,unsigned char c)
dev->quhd[c] = 0;
}
workreq = dev->quereq[c][dev->quhd[c]];
if (dev->id[c][scmd_id(workreq)].curr_req == NULL) {
if (dev->id[c][scmd_id(workreq)].curr_req == 0) {
dev->id[c][scmd_id(workreq)].curr_req = workreq;
dev->last_cmd[c] = scmd_id(workreq);
goto cmd_subp;
Expand Down
12 changes: 6 additions & 6 deletions trunk/drivers/scsi/hptiop.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
if (!(pci_resource_flags(pcidev, index) & IORESOURCE_MEM)) {
printk(KERN_ERR "scsi%d: pci resource invalid\n",
hba->host->host_no);
return NULL;
return 0;
}

mem_base_phy = pci_resource_start(pcidev, index);
Expand All @@ -454,7 +454,7 @@ static void __iomem *hptiop_map_pci_bar(struct hptiop_hba *hba, int index)
if (!mem_base_virt) {
printk(KERN_ERR "scsi%d: Fail to ioremap memory space\n",
hba->host->host_no);
return NULL;
return 0;
}
return mem_base_virt;
}
Expand All @@ -476,11 +476,11 @@ static void hptiop_unmap_pci_bar_itl(struct hptiop_hba *hba)
static int hptiop_map_pci_bar_mv(struct hptiop_hba *hba)
{
hba->u.mv.regs = hptiop_map_pci_bar(hba, 0);
if (hba->u.mv.regs == NULL)
if (hba->u.mv.regs == 0)
return -1;

hba->u.mv.mu = hptiop_map_pci_bar(hba, 2);
if (hba->u.mv.mu == NULL) {
if (hba->u.mv.mu == 0) {
iounmap(hba->u.mv.regs);
return -1;
}
Expand Down Expand Up @@ -1210,8 +1210,8 @@ static void hptiop_remove(struct pci_dev *pcidev)

static struct hptiop_adapter_ops hptiop_itl_ops = {
.iop_wait_ready = iop_wait_ready_itl,
.internal_memalloc = NULL,
.internal_memfree = NULL,
.internal_memalloc = 0,
.internal_memfree = 0,
.map_pci_bar = hptiop_map_pci_bar_itl,
.unmap_pci_bar = hptiop_unmap_pci_bar_itl,
.enable_intr = hptiop_enable_intr_itl,
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/scsi/qla1280.c
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp)

/* Check for room in outstanding command list. */
for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS &&
ha->outstanding_cmds[cnt] != NULL; cnt++);
ha->outstanding_cmds[cnt] != 0; cnt++);

if (cnt >= MAX_OUTSTANDING_COMMANDS) {
status = 1;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/video/aty/atyfb_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -3356,7 +3356,7 @@ static int __devinit atyfb_setup_generic(struct pci_dev *pdev, struct fb_info *i

info->fix.mmio_start = raddr;
par->ati_regbase = ioremap(info->fix.mmio_start, 0x1000);
if (par->ati_regbase == NULL)
if (par->ati_regbase == 0)
return -ENOMEM;

info->fix.mmio_start += par->aux_start ? 0x400 : 0xc00;
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/video/aty/radeon_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2277,8 +2277,8 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
do {
rinfo->fb_base = ioremap (rinfo->fb_base_phys,
rinfo->mapped_vram);
} while (rinfo->fb_base == NULL &&
((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM));
} while ( rinfo->fb_base == 0 &&
((rinfo->mapped_vram /=2) >= MIN_MAPPED_VRAM) );

if (rinfo->fb_base == NULL) {
printk (KERN_ERR "radeonfb (%s): cannot map FB\n",
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/video/matrox/matroxfb_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static inline int mga_ioremap(unsigned long phys, unsigned long size, int flags,
virt->vaddr = ioremap_nocache(phys, size);
else
virt->vaddr = ioremap(phys, size);
return (virt->vaddr == NULL); /* 0, !0... 0, error_code in future */
return (virt->vaddr == 0); /* 0, !0... 0, error_code in future */
}

static inline void mga_iounmap(vaddr_t va) {
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/video/sis/sis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5787,7 +5787,7 @@ sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
} else {
struct sis_video_info *countvideo = card_list;
ivideo->cardnumber = 1;
while((countvideo = countvideo->next) != NULL)
while((countvideo = countvideo->next) != 0)
ivideo->cardnumber++;
}

Expand Down
24 changes: 4 additions & 20 deletions trunk/fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ _xfs_buf_lookup_pages(
if (unlikely(page == NULL)) {
if (flags & XBF_READ_AHEAD) {
bp->b_page_count = i;
for (i = 0; i < bp->b_page_count; i++)
unlock_page(bp->b_pages[i]);
return -ENOMEM;
}

Expand Down Expand Up @@ -418,24 +416,17 @@ _xfs_buf_lookup_pages(
ASSERT(!PagePrivate(page));
if (!PageUptodate(page)) {
page_count--;
if (blocksize >= PAGE_CACHE_SIZE) {
if (flags & XBF_READ)
bp->b_flags |= _XBF_PAGE_LOCKED;
} else if (!PagePrivate(page)) {
if (blocksize < PAGE_CACHE_SIZE && !PagePrivate(page)) {
if (test_page_region(page, offset, nbytes))
page_count++;
}
}

unlock_page(page);
bp->b_pages[i] = page;
offset = 0;
}

if (!(bp->b_flags & _XBF_PAGE_LOCKED)) {
for (i = 0; i < bp->b_page_count; i++)
unlock_page(bp->b_pages[i]);
}

if (page_count == bp->b_page_count)
bp->b_flags |= XBF_DONE;

Expand Down Expand Up @@ -755,7 +746,6 @@ xfs_buf_associate_memory(
bp->b_count_desired = len;
bp->b_buffer_length = buflen;
bp->b_flags |= XBF_MAPPED;
bp->b_flags &= ~_XBF_PAGE_LOCKED;

return 0;
}
Expand Down Expand Up @@ -1103,10 +1093,8 @@ _xfs_buf_ioend(
xfs_buf_t *bp,
int schedule)
{
if (atomic_dec_and_test(&bp->b_io_remaining) == 1) {
bp->b_flags &= ~_XBF_PAGE_LOCKED;
if (atomic_dec_and_test(&bp->b_io_remaining) == 1)
xfs_buf_ioend(bp, schedule);
}
}

STATIC void
Expand Down Expand Up @@ -1137,9 +1125,6 @@ xfs_buf_bio_end_io(

if (--bvec >= bio->bi_io_vec)
prefetchw(&bvec->bv_page->flags);

if (bp->b_flags & _XBF_PAGE_LOCKED)
unlock_page(page);
} while (bvec >= bio->bi_io_vec);

_xfs_buf_ioend(bp, 1);
Expand Down Expand Up @@ -1178,8 +1163,7 @@ _xfs_buf_ioapply(
* filesystem block size is not smaller than the page size.
*/
if ((bp->b_buffer_length < PAGE_CACHE_SIZE) &&
((bp->b_flags & (XBF_READ|_XBF_PAGE_LOCKED)) ==
(XBF_READ|_XBF_PAGE_LOCKED)) &&
(bp->b_flags & XBF_READ) &&
(blocksize >= PAGE_CACHE_SIZE)) {
bio = bio_alloc(GFP_NOIO, 1);

Expand Down
19 changes: 0 additions & 19 deletions trunk/fs/xfs/linux-2.6/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,6 @@ typedef enum {
_XBF_PAGES = (1 << 18), /* backed by refcounted pages */
_XBF_RUN_QUEUES = (1 << 19),/* run block device task queue */
_XBF_DELWRI_Q = (1 << 21), /* buffer on delwri queue */

/*
* Special flag for supporting metadata blocks smaller than a FSB.
*
* In this case we can have multiple xfs_buf_t on a single page and
* need to lock out concurrent xfs_buf_t readers as they only
* serialise access to the buffer.
*
* If the FSB size >= PAGE_CACHE_SIZE case, we have no serialisation
* between reads of the page. Hence we can have one thread read the
* page and modify it, but then race with another thread that thinks
* the page is not up-to-date and hence reads it again.
*
* The result is that the first modifcation to the page is lost.
* This sort of AGF/AGI reading race can happen when unlinking inodes
* that require truncation and results in the AGI unlinked list
* modifications being lost.
*/
_XBF_PAGE_LOCKED = (1 << 22),
} xfs_buf_flags_t;

typedef enum {
Expand Down
17 changes: 6 additions & 11 deletions trunk/fs/xfs/linux-2.6/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,19 @@ xfs_file_release(
return -xfs_release(XFS_I(inode));
}

/*
* We ignore the datasync flag here because a datasync is effectively
* identical to an fsync. That is, datasync implies that we need to write
* only the metadata needed to be able to access the data that is written
* if we crash after the call completes. Hence if we are writing beyond
* EOF we have to log the inode size change as well, which makes it a
* full fsync. If we don't write beyond EOF, the inode core will be
* clean in memory and so we don't need to log the inode, just like
* fsync.
*/
STATIC int
xfs_file_fsync(
struct file *filp,
struct dentry *dentry,
int datasync)
{
int flags = FSYNC_WAIT;

if (datasync)
flags |= FSYNC_DATA;
xfs_iflags_clear(XFS_I(dentry->d_inode), XFS_ITRUNCATED);
return -xfs_fsync(XFS_I(dentry->d_inode));
return -xfs_fsync(XFS_I(dentry->d_inode), flags,
(xfs_off_t)0, (xfs_off_t)-1);
}

/*
Expand Down
8 changes: 8 additions & 0 deletions trunk/fs/xfs/linux-2.6/xfs_vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ static inline void vn_atime_to_time_t(bhv_vnode_t *vp, time_t *tt)
#define ATTR_NOLOCK 0x200 /* Don't grab any conflicting locks */
#define ATTR_NOSIZETOK 0x400 /* Don't get the SIZE token */

/*
* Flags to vop_fsync/reclaim.
*/
#define FSYNC_NOWAIT 0 /* asynchronous flush */
#define FSYNC_WAIT 0x1 /* synchronous fsync or forced reclaim */
#define FSYNC_INVAL 0x2 /* flush and invalidate cached data */
#define FSYNC_DATA 0x4 /* synchronous fsync of data only */

/*
* Tracking vnode activity.
*/
Expand Down
Loading

0 comments on commit eb9ac48

Please sign in to comment.